Data synchronization method, system and computer readable storage medium facing shared binary buffer
By adaptively switching synchronization modes and optimizing engine-level low-overhead dirty page tracking, the metadata overhead and main thread usage issues of shared binary buffer synchronization are resolved, achieving efficient field-level conflict-free merging and network adaptation.
Patent Information
- Application Number
- CN202611354234.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-02
- Publication Date
- 2026-11-24
AI Technical Summary
Existing technologies suffer from problems such as huge metadata overhead, inability to merge based on semantic field differences, and high computational power consumption of the main thread when synchronizing shared binary buffers.
By loading the shared binary buffer mode definition configured in the webpage through the browser engine, a dedicated conflict-free copy data type merging function is generated. The synchronization mode is adaptively switched according to the network round-trip latency. Combined with engine-level low-overhead dirty page tracking and adaptive multi-mode synchronization, the data synchronization process is optimized.
It achieves conflict-free merging, reduces metadata storage overhead, reduces the computational overhead of the main thread of the webpage, adapts to various network environments, and reduces engine maintenance costs.
Smart Images

Figure CN123157972A_ABST
Abstract
Description
Technical Field
[0001] This application relates to browser cross-device real-time collaboration, distributed conflict-free data replication and shared memory synchronization technologies, and particularly to data synchronization methods, systems and computer-readable storage media for shared binary buffers. Background Technology
[0002] Real-time web collaboration scenarios require multi-terminal synchronization of binary shared memory data. Current mainstream CRDT (Conflict-free Replicated Data Type) synchronization solutions fall into two categories: general text / JSON frameworks and customized business protocols. General CRDT frameworks, such as Yjs, rely on element-level metadata to record data changes, enabling conflict-free merging of structured data. However, when synchronizing binary shared buffers, they incur extremely high metadata storage overhead. Furthermore, they cannot match and adapt merging rules based on different business fields within the binary data; they can only perform overall coverage synchronization, failing to achieve precise, conflict-free merging at the field level. This is the core flaw of existing binary buffer CRDT synchronization solutions. Summary of the Invention
[0003] This application provides a data synchronization method, system, and computer-readable storage medium for shared binary buffers, which solves one or more technical problems in existing shared binary buffer synchronization, such as huge metadata overhead, inability to merge data based on semantic field differences, and the consumption of main thread computing power for tracking changes at the upper layer of web pages.
[0004] On one hand, embodiments of this application provide a data synchronization method for a shared binary buffer, the method comprising: The shared binary buffer mode definition for browser engine loading web pages; The browser engine generates a dedicated conflict-free copy data type merging function for each field based on the parameters of each field in the schema definition; The browser engine detects the network round-trip latency between collaborative terminals, adaptively switches the synchronization mode according to the network round-trip latency range, and calls the merging function of the corresponding field to complete the fusion of the received remote data when each synchronization mode is executed.
[0005] Preferably, the adaptive switching of synchronization mode based on the network round-trip time interval specifically includes: When the network round-trip latency is at the local area network low latency, switch to operation stream synchronization mode; When the network round-trip latency is equivalent to that of a wide area network, switch to incremental state synchronization mode. When network round-trip latency is caused by disconnection and reconnection, switch to full state synchronization mode.
[0006] Preferably, the method further includes: When executing a write instruction to the shared binary buffer, the process jumps to the browser engine's built-in proxy function; After the browser engine proxy function completes the writing of the raw data to the buffer, it executes inline hardware tracer machine instructions to update the dirty page bitmap and logical timestamp. The browser engine's background synchronous coroutine asynchronously reads the updated dirty page bitmap, collects the changed pages, generates a synchronous data packet, and pushes it to the collaborating device on the other end.
[0007] Preferably, the hardware tracking machine instructions include dirty page tracking instructions and logical timestamp auto-incrementing instructions.
[0008] Preferably, the method further includes: The browser engine continuously records the online / offline duration and global vector clock of each collaborative device; When a device is offline for longer than a preset grace period, the browser engine iterates through the global vector clock to determine whether the clocks of online devices are not earlier than the last operation clock of the offline device. If so, the browser engine will merge all incremental and decremental data of the offline device into a unified compressed entry and delete the independent vector corresponding to that device.
[0009] Preferably, when the webpage does not have a configured mode definition, the shared binary buffer without a configured mode definition automatically enables the page-level last-write priority merging rule, directly supporting cross-device synchronization.
[0010] Preferably, the shared binary buffer mode definition configured in the webpage is used to describe the internal field rules of the shared binary buffer, including the memory offset, field data type, and conflict-free copy data type primitives corresponding to each business field in the shared binary buffer.
[0011] On the other hand, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the aforementioned method.
[0012] Furthermore, embodiments of this application provide a data synchronization system for a shared binary buffer, the system comprising a mode definition loading module, a merge function generation module, and a mode switching module, wherein: The mode definition loading module is used to load the shared binary buffer mode definition configured on the webpage. The merge function generation module is used to generate a dedicated, conflict-free copy data type merge function for each field based on the parameters of each field in the pattern definition. The mode switching module is used to detect the network round-trip latency between terminals, adaptively switch the synchronization mode according to the network round-trip latency range, and call the merging function of the corresponding field to complete the fusion of the received remote data when each synchronization mode is executed.
[0013] Compared with existing technologies, the embodiments of this application split binary semantic fields through pattern definition, and use optimal merging rules for different business data, which neither loses local concurrent modifications nor generates excessive metadata. At the same time, the merging logic of the embodiments of this application can be compatible with multiple network synchronization modes, without the need to reconstruct synchronization code for different network environments, and can be universally adapted to various binary collaborative services, effectively reducing engine maintenance costs. Attached Figure Description
[0014] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a flowchart of a data synchronization method for a shared binary buffer according to an embodiment of this application; Figure 2 This is a diagram illustrating the overall data synchronization architecture for a shared binary buffer, as described in an embodiment of this application. Figure 3 This is a flowchart of the engine-level dirty page low-overhead tracing optimization scheme in an embodiment of this application; Figure 4 This is a flowchart of the CRDT device vector recycling optimization scheme in an embodiment of this application; Figure 5 This is a block diagram of a data synchronization system architecture for a shared binary buffer, as described in an embodiment of this application. Detailed Implementation
[0015] The technical solution of this application will be clearly and completely described below with reference to the concepts in the embodiments of this application. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0016] As mentioned earlier, in scenarios such as multi-user web collaboration and real-time cloud drawing, multiple terminals need to synchronize large blocks of binary memory. While the standard SharedArrayBuffer (SAB) in browsers can achieve multi-threaded memory sharing on a single device, its native interface lacks cross-device synchronization capabilities. The industry generally uses CRDT technology to solve the problem of concurrent modification conflicts across multiple terminals. Current mainstream CRDT solutions have three unresolved shortcomings: First, the problem of metadata explosion and loss of partial modifications during whole-block merging in general CRDT libraries. For example, CRDT architectures like Yjs, designed for JSON and string structured data, maintain independent metadata for each data element. Synchronizing a 1MB binary buffer will generate tens of MB of additional metadata, and the storage and transmission overhead cannot adapt to large binary scenarios. Another example is Automerge, which only supports whole-block buffer overwrite synchronization and cannot differentiate between different business fields within the buffer for differentiated merging. For instance, when counting, coordinate, and static canvas data coexist, only a whole overwrite is possible, leading to the loss of partial modifications. Second, the problem of closed and non-universal protocols in dedicated collaboration tools. For example, Figma uses a proprietary synchronization protocol that only adapts to design canvases and cannot be universally used for binary business scenarios such as games and video editing. The third type is a low-level solution based on byte-by-byte tracing. This solution executes multiple marking instructions when each byte is written, which results in extremely high computational overhead for the main thread of the webpage and causes page lag.
[0017] Meanwhile, existing CRDT synchronization protocols are all in a fixed mode and do not automatically adjust the synchronization strategy according to the latency of LAN and WAN networks. In LAN scenarios, using full synchronization will lead to redundant transmission, and in WAN scenarios, continuously pushing single operation streams will continuously occupy uplink bandwidth. In addition, for incremental data from multiple devices such as counters and accumulators, the existing framework lacks a secure vector reclamation mechanism. After long-term collaboration, the device vectors continue to expand, and memory consumption continues to increase.
[0018] To address the aforementioned one or more shortcomings, this application's embodiments rely on the browser engine's underlying permissions to design schemes such as schema semantic-driven composite CRDT, engine-level low-overhead dirty page tracking, and adaptive multi-mode synchronization. These solutions can resolve issues related to the overhead, merging, and network adaptation of binary buffer cross-device synchronization. These are described in detail below with reference to the accompanying drawings.
[0019] See Figure 1 and Figure 2 ,in Figure 1 The detailed flow of the data synchronization method for a shared binary buffer according to an embodiment of this application is shown; Figure 2A diagram illustrating the overall data synchronization architecture is provided. This diagram presents two devices, but in practical applications, there may be two or more collaborating devices. For ease of explanation, the following description of embodiments may primarily focus on the perspective of one device, but this does not preclude the existence of identical execution steps, functional modules, and elements on other devices. For example, in... Figure 2 A certain device has a service code layer that synchronizes data to device B. Therefore, the service code layer of device B is not shown in the diagram. However, when device B may need to synchronize its data to other devices at some point, a service code layer must also exist in device B. The specific steps of this embodiment include: Step S11: The browser engine loads the shared binary buffer mode definition configured for the webpage; The entity executing this step can be the browser engine's memory management module, and the action object is the shared binary buffer schema definition parameter (Schema) passed in by the webpage. The Schema is a configuration passed to the browser engine by the webpage developer, specifically describing the internal field rules of the SharedArrayBuffer (see [link to documentation]). Figure 2 Device B in the configuration includes key information such as: total buffer length, memory offset of each business field in the buffer, basic data type of the field (int32, float64, raw, etc.), CRDT primitive type bound to the field, and block size of large blocks of binary data. The browser engine reads the pattern definition and extracts an array of independent field descriptions as input for generating the merging logic. However, it should be noted that in some cases, the webpage may not have passed a pattern definition. In this case, the engine will automatically generate a default page-level merging rule without additional configuration, which will be further explained in subsequent embodiments. The following is an example of pseudocode for a webpage pattern definition: new SharedArrayBuffer(4096, { sync: "cross-device", schema: { playerCount: { offset: 0, type: "int32", crdt: "lww"}, score: { offset: 4, type: "int32", crdt: "pn-counter"} } }) This is a typical JSON schema, which clearly separates two independent fields and their respective memory locations and synchronization rules.
[0020] Step S12: The browser engine generates a dedicated conflict-free copy data type merging function for each field based on the parameters of each field in the schema definition; This step receives the field description array output by S11 as input. The execution entity can be a module built into the browser engine that performs compilation. In this step, the browser engine matches the CRDT primitives bound to the read fields, loads the corresponding conflict merging logic, and generates a global merge function table. CRDT is a distributed data structure algorithm whose core function is to automatically merge all device data into a completely consistent state when multiple devices modify the same data simultaneously, without server arbitration or locking, thus solving the problem of conflicts in real-time collaboration among multiple users. CRDT primitives are used in conjunction with the schema and can be one or more of the following: LWW (Last Write First), PN-Counter (Positive and Negative Counter), Max (Maximum Value Register), Accumulator, and LWW-Block (Page-Level Last Write First). Therefore, when the field type is a counter field, the PN-Counter positive and negative counter merging logic is matched; when the field is a static image block, the page-level overwrite logic is matched. The generated merge function can be stored in the global function table for subsequent steps to call. When a remote change is received subsequently, the corresponding merge function is matched according to the change offset to perform conflict-free fusion and output the merged buffer data.
[0021] Step S13: The browser engine detects the network round-trip latency between collaborative terminals, adaptively switches the synchronization mode according to the latency range, and calls the merging function of the corresponding field to complete the fusion of the received remote data when each synchronization mode is executed. This step receives the merge function table output by S12 as input, and the execution entity can be the browser engine's synchronization scheduling module (synchronization mode switching module). In this step, the browser engine continuously detects the RTT (Round-Trip Time) latency between collaborating devices. In this embodiment, it can specifically distinguish between three scenarios: low latency in local area networks, medium latency in wide area networks, and disconnection and reconnection, and automatically match the optimal synchronization strategy according to different scenarios, without requiring developers to manually configure the synchronization mode. For example, when RTT < 5ms (typically within a local area network, such as multiple computers or tablets under the same router), the system can switch to the low-latency LAN operation stream (Op-Stream) mode corresponding to this scenario. In this mode, each memory write generates a single tiny operation data packet, which is broadcast to the other end in real time, resulting in the lowest latency and making it suitable for local low-latency real-time collaboration such as online games and local drawing. When 5ms ≤ RTT ≤ 100ms (typically within a regular internet wide area network), the system can switch to the medium-latency wide area network incremental state (Delta-State) mode corresponding to this scenario. In this mode, all dirty pages are collected at fixed clock cycles, and changes are compressed and sent in batches to reduce the bandwidth loss caused by frequent small packets in the previous mode, thereby balancing latency and traffic. When a disconnection and reconnection occurs, causing a large difference in the vector clocks at both ends, the system can switch to the full-state mode. In this mode, a full binary buffer snapshot is compressed and synchronized at once, quickly aligning the data at both ends and catching up on the data difference caused by a long disconnection. In the switching between different modes, the embodiments of this application can switch "adaptively". Adaptive means that no manual intervention is required throughout the process. When the RTT value changes dynamically, the engine automatically and seamlessly switches modes. For example, when a computer device switches from a local area network to a mobile hotspot, the RTT increases from 3ms to 60ms. The synchronization mode automatically switches from operation flow to incremental state, and the synchronization data packet format changes automatically.
[0022] After explaining the mode switching, it should be noted that the data formats (structures) transmitted in the three modes mentioned above are completely different. However, in the embodiments of this application, the same set of field merging functions can be called, and their underlying merging logic is completely universal. There is no redundancy of multiple sets of merging code, thus ensuring that semantic-level conflict-free merging can be achieved regardless of the transmission method, ensuring the eventual consistency of conflict-free copied data types. The specific data merging and fusion process is manifested according to different modes as follows: (1) Operation Stream Synchronization Mode: When the remote end receives a single write operation, because the data packet carries a memory offset, the browser engine retrieves the Schema field based on the offset, matches the CRDT merge function specific to the field, performs conflict merging only on the field, and keeps the rest of the memory data unchanged; (2) Incremental state synchronization mode: When the remote end receives compressed dirty page differential data, it decompresses and traverses all fields in the changed page, and calls the corresponding merging function one by one to complete the concurrent fusion of multiple fields; (3) Full state synchronization mode: When the remote decompresses the complete buffer snapshot, the merge function is called field by field, and the local and snapshot data are uniformly converged according to the CRDT rules.
[0023] It's important to note that "fusion" in remote data fusion here is not the same as simple overwriting. When multiple devices concurrently modify the same field, conflicts are automatically eliminated using CRDT rules such as LWW / PN-Counter. Legitimate modifications from either end are not discarded, ensuring complete consistency between the buffers on both ends and satisfying the eventual consistency property of CRDT. After synchronization, the local shared binary buffer is updated and then made available for use by web page read commands such as Atomics.wait and Atomics.read.
[0024] Compared to traditional CRDT synchronization binary buffers that require complete overwriting or massive amounts of element metadata, this application's embodiment splits binary semantic fields using a schema. Different business data use optimal merging rules, ensuring neither the loss of local concurrent modifications nor the generation of excessive metadata. Furthermore, unlike existing CRDT synchronization schemes that fix only a single transmission mode, this application's embodiment uses a single merging logic compatible with multiple network synchronization modes. It eliminates the need to reconstruct synchronization code for different network environments, providing generalized adaptation to various binary collaborative services and effectively reducing engine maintenance costs.
[0025] The aforementioned embodiments effectively solve the problems of field differentiation merging and multi-mode synchronization. However, if each binary write operation of the webpage is recorded through a JS upper-level proxy, it will generate a large amount of main thread computation overhead. Existing solutions require multiple marking instructions for each write, affecting page rendering and interaction smoothness. Therefore, this application's embodiments consider designing an optimization scheme for engine-level inline dirty page tracking. See also Figure 3 The figure illustrates the flow of the optimization scheme for low-overhead tracing of engine-level dirty pages according to an embodiment of this application. The specific steps include: Step S21: When executing the shared binary buffer write instruction, jump to the browser engine's built-in proxy function; In this step, when a binary buffer write instruction is executed upon receiving data, the web page script calls shared memory write interfaces such as Atomics.store. The browser engine compiler, based on the engine's cross-level inlining rules, hijacks and replaces the shared memory write interface (unified interception of all buffer write operations), automatically embedding the engine proxy logic. This means that an engine proxy layer is present in the device (see...). Figure 2(Device A and Device B). Web developers only need to write normal JavaScript code; no code modification is required, thus not increasing the size of the webpage's business logic code. The code does not directly manipulate memory during runtime; instead, it automatically jumps to a pre-packaged proxy function provided by the engine.
[0026] Step S22: After the browser engine proxy function completes the writing of the original data to the buffer, it executes hardware tracing machine instructions to update the dirty page bitmap and logical timestamp; This step receives the write memory index from S21 as input and completes the memory write required by the business logic, ensuring that the original read and write logic of the webpage remains completely unaffected. The key aspect of this step is the execution of inline hardware tracing machine instructions. In this embodiment, this mainly includes two hardware machine instructions (without upper-layer JS computation overhead): The first instruction modifies the global dirty page bitmap marker according to the write memory page offset. Specifically, it calculates the page number based on the write address by running an OR operation instruction, sets the corresponding marker in the dirty page bitmap to 1, and records that the memory page has been modified. The second instruction is an increment instruction that increments the global Lamport logical timestamp by 1, serving as the timing basis for CRDT conflict determination. Both instructions are native CPU operations with extremely low computation time and will not block the webpage rendering thread. This differs from traditional solutions that add multiple layers of judgment logic at the JS layer, requiring dozens of instructions to be written at once, resulting in significant resource consumption. Furthermore, since the dirty page bitmap is stored in the browser engine's global shared memory area and does not belong to the Software Fault Isolation (SFI) domain of a single web page tag, the web page script cannot tamper with the tracking markers and timestamps, ensuring that the change records cannot be forged by malicious code and guaranteeing integrity.
[0027] Step S23: The browser engine background synchronous coroutine asynchronously reads the updated dirty page bitmap, collects the changed pages, generates a synchronous data packet, and pushes it to the peer cooperating device; This step receives the updated dirty page bitmap data from S22 as input. It executes in the background asynchronous coroutine without blocking the main webpage thread. It periodically scans the updated dirty page bitmap, traverses the pages marked as modified, extracts the page memory offset and corresponding field information, and then assembles a synchronization data packet based on the current RTT network latency, matching the data format corresponding to the selected synchronization mode. Finally, it pushes the packet to other collaborating terminals. For example, Figure 2 Device B in the diagram. After each scan, the page dirty mark is reset, forming a closed-loop tracing logic of write mark - periodic acquisition.
[0028] As mentioned above, compared with the traditional JS layer change tracking scheme that requires dozens of operation instructions for a single write, the embodiment of this application only adds two underlying hardware instructions. The overhead of a single write tracking is negligible, and the metadata occupies only a very small proportion of the buffer memory. The network IO overhead is completely decoupled from the main thread of the web page. Compared with the metadata storage overhead of frameworks such as Yjs, it is reduced by thousands of times, and the main thread of the web page will not be stuck due to the synchronization mark.
[0029] In the foregoing embodiments, various primitive types of CRDT were mentioned. Among them, the positive and negative counters and accumulators, which are CRDT primitives, require maintaining an independent incremental vector for each online device. This leads to the continuous accumulation of offline device entries in long-term multi-person collaboration scenarios, causing the vector memory to expand infinitely. However, the existing framework lacks a safe reclamation mechanism, consuming a large amount of runtime memory. Therefore, this application embodiment considers proposing an optimized scheme for CRDT device vector reclamation based on the aforementioned solution. See also Figure 4 The diagram illustrates the flow of the CRDT equipment vector recycling optimization scheme, including the following steps: Step S31: The browser engine continuously records the offline duration and global vector clock of each collaborative device; This step is executed by the browser engine's memory management module, which continuously collects the online / offline duration of all terminals and the logical clock (vector clock) corresponding to the last operation on each device. This data is used as the basis for data reclamation judgment, preventing premature reclamation that could lead to data loss. Therefore, the browser engine backend needs to maintain two global record tables in real time: a device status table, which records each device's unique identifier, current online / offline status, and cumulative offline duration; and a global vector clock table, which stores the latest Lamport time series values for all devices. Maintaining these two tables provides two dimensions for subsequent reclamation judgments. This setup is because relying solely on offline duration for reclamation carries the risk of data loss. Using the vector clock for causal verification ensures the causal safety of the reclamation operation, preventing the deletion of incremental data that has not yet propagated to other devices. This step involves device vector storage. In fact, in the aforementioned embodiments, the field type is identified when parsing the schema. If the field is PN-Counter / Accumulator, the engine will allocate a device-independent vector storage area for that field. If there is no schema definition, there is no device vector. In the aforementioned embodiments, when generating the CRDT merging function, a global vector clock management container is created synchronously, which is also the only way to continuously record the timing and online status of each device.
[0030] Step S32: When the device is offline for longer than the preset grace period, the browser engine traverses the global vector clock to determine whether the clocks of all online devices are later than the last operation clock of the offline device; if so, proceed to step S33. This step receives device status data collected by S31 as input. The verification logic for this step only begins when the cumulative offline time of a recorded device exceeds a preset grace period (e.g., 5 minutes by default). The precondition for recycling is met only when all online terminals have synchronized all incremental data of the offline device, ensuring that recycling does not lose unsynchronized modifications. More specifically, when the clock of every online device is greater than or equal to the last operation clock of the offline device, it means that all modified data of the offline device has been fully synchronized and distributed to all online terminals, and there are no unsynchronized increments. If an online device's clock is lower, it indicates that modifications on some offline devices have not yet been synchronized, and recycling is skipped, continuing to retain the independent vector for that device. The vector clock in this step is updated locally on the online device vector clock after each remote data merging, ensuring the latest information is obtained when traversing the global vector clock.
[0031] Step S33: The browser engine merges all incremental and decremented data from offline devices into a unified compressed entry and deletes the device's independent vector. Under the conditions of satisfying the aforementioned steps, this step performs a vector data merging operation, taking into account both memory release and data semantic equivalence. Specifically, the steps may include reading all incremental and decrement vector data corresponding to the offline device's PN-Counter and Accumulator; merging all increments and values of that device into a globally unified compressed entry, ensuring that the total score and statistical values of the buffer before and after merging are completely consistent (semantic equivalence); and deleting the device-specific independent vector and device record from the global vector clock and device data table, releasing the corresponding runtime memory. This step cleans up redundant vectors, simplifies the global vector set, and reduces the engine's long-term runtime memory usage. The compressed entry completed in this step will participate in the CRDT merging calculation in the data fusion of the aforementioned embodiments. The merging logic is unaffected by the reclamation operation, ensuring data semantic consistency.
[0032] This embodiment automatically cleans up redundant vector entries of offline devices in long-term multi-person collaboration scenarios to avoid continuous memory increases. At the same time, it performs causal verification based on vector clocks, and the recycling operation will not disrupt the data consistency of multiple terminals, thus solving the memory expansion defect of counter-type CRDTs during long-term operation.
[0033] The aforementioned embodiments are all based on the existence of a schema. However, as mentioned earlier, there may be situations where no schema exists. For example, some lightweight web pages may not have a custom field schema. Compiling the complete field merging logic would increase engine initialization time, thus requiring configuration-free compatibility logic. When the browser engine detects that the web page has not passed schema definition parameters, the browser engine automatically enables the page-level last-write priority merging rule with a predefined memory block as the smallest granularity, directly supporting cross-device synchronization without parsing the field structure. Under this optimization approach, lightweight collaborative pages do not need to write field configurations and can achieve cross-device synchronization of binary buffers out of the box, thereby reducing development and integration costs while retaining all the performance advantages of underlying dirty page tracking and adaptive synchronization.
[0034] The foregoing description details the method embodiments provided in this application. In fact, this application also provides corresponding system embodiments. See [link to relevant documentation]. Figure 5 This diagram illustrates a structural block diagram of an embodiment of a data synchronization system for a shared binary buffer. The data synchronization system U50 of this embodiment includes a mode definition loading module U51, a merge function generation module U52, and a mode switching module U53, wherein: The schema definition loading module U51 is used to load the shared binary buffer schema definition of the web page configuration; The merge function generation module U52 is used to generate a dedicated, conflict-free copy data type merge function for each field based on the parameters of each field in the schema definition. The mode switching module U53 is used to detect the network round-trip latency between terminals, adaptively switch the synchronization mode according to the network round-trip latency range, and call the merging function of the corresponding field to complete the fusion of the received remote data when each synchronization mode is executed.
[0035] Based on the same principle, the aforementioned system embodiments can also be optimized, and other optimized modules can be added to the system. For example, in order to solve the problem of a large amount of main thread computation overhead generated every time a webpage performs a binary write operation, this application embodiment can provide an optimized scheme for dirty page tracking, adding a proxy write module U54, a hardware tracking module U55, and a data packet generation module U56 to the system. The proxy write module U54 is used to jump to the browser engine's built-in proxy function when executing the shared binary buffer write instruction, and the proxy function completes the writing of the original data in the buffer. The hardware tracking module U55 is used to execute hardware tracking machine instructions to update the dirty page bitmap and logical timestamp after completing the writing of the original data in the buffer. The data packet generation module U56 is used to read the updated dirty bitmap step by step, collect the changed pages, generate synchronization data packets, and push them to the peer cooperating device. For example, to address the issue of continuous accumulation of offline device entries and infinite expansion of vector memory in long-term multi-user collaboration scenarios, a status recording module, a status judgment module, and a device vector recycling module can be added to the system. The status recording module continuously records the online / offline duration and global vector clock of each collaborative device. The status judgment module, when a device's offline duration exceeds a preset grace period, uses the browser engine to traverse the global vector clock and determine if the clocks of all online devices are later than the last operation clock of the offline device. The device vector processing module merges all incremental and decremental data from offline devices into a unified compressed entry and deletes the device's independent vector. These optimizations in different directions further improve the system's functionality and meet the needs of various scenarios.
[0036] Both the aforementioned system embodiments and the further optimized technical functional modules can achieve the same technical effects as the aforementioned method embodiments. To avoid repetition, they will not be elaborated here.
[0037] Furthermore, the technical solution of this application can be formed on a computer-readable storage medium to form a computer program. The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
[0038] The embodiments of this application can achieve all the inventive objectives using the aforementioned software; therefore, the software portion has been primarily described. Those skilled in the art should understand that the embodiments of this application can be provided as an apparatus, system, or related computer program product. Therefore, this application can be implemented in some cases as a completely hardware embodiment, or as a completely software embodiment, or as an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0039] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0040] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0041] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0042] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0043] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0044] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0045] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0046] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A data synchronization method for a shared binary buffer, characterized in that, The method includes: The shared binary buffer mode definition for browser engine loading web pages; The browser engine generates a dedicated conflict-free copy data type merging function for each field based on the parameters of each field in the schema definition; The browser engine detects the network round-trip latency between collaborative terminals, adaptively switches the synchronization mode according to the network round-trip latency range, and calls the merging function of the corresponding field to complete the fusion of the received remote data when each synchronization mode is executed.
2. The method according to claim 1, characterized in that, The adaptive switching of synchronization mode based on network round-trip time interval specifically includes: When the network round-trip latency is at the low latency of the local area network, switch to operation stream synchronization mode; When the network round-trip latency is equivalent to that of a wide area network, switch to incremental state synchronization mode. When network round-trip latency is caused by disconnection and reconnection, switch to full state synchronization mode.
3. The method according to claim 1, characterized in that, The method further includes: When executing a write instruction to the shared binary buffer, the process jumps to the browser engine's built-in proxy function; After the browser engine proxy function completes the writing of the original data to the buffer, it executes inline hardware tracing machine instructions to update the dirty page bitmap and logical timestamp. The browser engine's background synchronous coroutine asynchronously reads the updated dirty page bitmap, collects the changed pages, generates a synchronous data packet, and pushes it to the collaborating device on the other end.
4. The method according to claim 3, characterized in that, The hardware tracing machine instructions include dirty page tracing instructions and logical timestamp auto-incrementing instructions.
5. The method according to claim 1, characterized in that, The method further includes: The browser engine continuously records the online / offline duration and global vector clock of each collaborative device; When a device is offline for longer than a preset grace period, the browser engine iterates through the global vector clock to determine whether the clocks of online devices are not earlier than the last operation clock of the offline device. If so, the browser engine will merge all incremental and decremental data of the offline device into a unified compressed entry and delete the independent vector corresponding to that device.
6. The method according to claim 1, characterized in that, The shared binary buffer mode definition configured in the webpage is used to describe the internal field rules of the shared binary buffer, including the memory offset, field data type, and conflict-free copy data type primitives corresponding to each business field in the shared binary buffer.
7. The method according to claim 1, characterized in that, When a webpage does not have a configured mode definition, the shared binary buffer without a configured mode definition automatically enables the page-level last-write-first-merge rule, directly supporting cross-device synchronization.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method as described in any one of claims 1 to 7.
9. A data synchronization system for a shared binary buffer, characterized in that, The system includes a mode definition loading module, a merge function generation module, and a mode switching module, wherein: The mode definition loading module is used to load the shared binary buffer mode definition configured on the webpage. The merge function generation module is used to generate a dedicated, conflict-free copy data type merge function for each field based on the parameters of each field in the pattern definition. The mode switching module is used to detect the network round-trip latency between terminals, adaptively switch the synchronization mode according to the network round-trip latency range, and call the merging function of the corresponding field to complete the fusion of the received remote data when each synchronization mode is executed.
