Multi-file synchronization method and electronic device

By determining the synchronization priority and predicting the synchronization rate of files on the client side, files with lower aging levels and larger synchronization data volumes are synchronized first, thus solving the problem of mutual interference during the synchronization of multiple files and improving synchronization efficiency and user experience.

CN115700493BActive Publication Date: 2026-07-24HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2021-07-22
Publication Date
2026-07-24

Smart Images

  • Figure CN115700493B_ABST
    Figure CN115700493B_ABST
Patent Text Reader

Abstract

The application provides a multi-file synchronization method and an electronic device. The method comprises the following steps: a client first determines the aging degree of a plurality of source file copies and the data volume of synchronization data when synchronizing the plurality of source file copies, and then determines the synchronization priority of the plurality of source file copies based on the aging degree and the data volume of the synchronization data, and finally the client synchronizes the plurality of source file copies according to the synchronization priority. The multi-file synchronization method provided by the application can comprehensively consider the aging degree of the source file copies and the data volume of the synchronization data, thereby avoiding the situation that the client always synchronizes the source file copies with small synchronization data first and then synchronizes the source file copies with large synchronization data which have not been synchronized for a long time, and reducing the average synchronization time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic technology, and in particular to a method and electronic device for synchronizing multiple files. Background Technology

[0002] With the development of communication technology and the popularization of smart devices, the era of Artificial Intelligence of Things (AIoT) is dawning. Benefiting from the improved distributed interconnection capabilities of operating systems, smart wearable devices, smart home devices, mobile terminals, and other devices can interact with each other via networks and collaborate to achieve specific functions based on this data interaction.

[0003] When the server shares one or more files to the client, the client stores those shared files in its local cache. When a user modifies a shared file on the client, the client needs to synchronize the modified file back to the server. For example, if a user shares a document file from their phone to their computer for editing, the computer needs to continuously synchronize the modified document file back to the phone.

[0004] To achieve synchronization of shared files between the client and the server, the client can synchronize immediately after each user modifies the shared file; alternatively, the client can accumulate a certain amount of synchronization data locally before synchronizing.

[0005] However, when there are multiple shared files between the client and the server that need to be synchronized, the synchronization processes of these independent shared files can interfere with each other, increasing synchronization time and reducing the user experience. Summary of the Invention

[0006] This application provides a multi-file synchronization method and an electronic device. The multi-file synchronization method provided in this application determines the synchronization priority of files based on their aging status and the amount of data to be synchronized, and then determines the synchronization order of files based on the synchronization priority. When a client implements this method to synchronize multiple files, it can ensure that the client will not prioritize synchronizing files with lower aging status, and it can reduce the average synchronization time of multiple files.

[0007] Firstly, this application provides a method for synchronizing multiple files, the method comprising:

[0008] The client obtains multiple file copies from the server; the client determines the synchronization information of the multiple file copies, including the amount of data to be synchronized and the aging level, the aging level corresponding to the duration for which the file copies have not been synchronized; the client determines the synchronization priority of the multiple file copies based on the synchronization information of the multiple file copies and a first preset condition; the first preset condition includes: when the aging level of the file copy is within a first range, the synchronization priority of the file copy is related to the aging level of the file copy; when the aging level of the file copy is within a second range, the synchronization priority of the file copy is related to the amount of data to be synchronized in the file copy.

[0009] In the above embodiments, the client can determine the synchronization priority of file copies based on the file's aging status and the amount of synchronized data. First, if the synchronization priority is determined solely by the amount of synchronized data, subsequent modifications to files will increase the amount of synchronized data, potentially leading to lower priority synchronization. Second, if synchronization is based solely on the file copy's aging status, the average synchronization time for the client will be longer. However, by implementing the multi-file synchronization method provided in this application, the client can ensure that no file copy on the client maintains a consistently high priority and remains unsynchronized, while also reducing the average synchronization time for multiple file copies.

[0010] In conjunction with some embodiments of the first aspect, in some embodiments, the client determines a first synchronization rate; the client determines a set of files to be synchronized based on the first synchronization rate and the priority of the plurality of file copies; the client synchronizes the file copies in the set of files to be synchronized.

[0011] In the above embodiments, after determining the synchronization priority of multiple file copies, the client can predict the synchronization rate and then determine the set of files to be synchronized, thereby avoiding the client accumulating all the files to be synchronized in the client's protocol stack or protocol stack cache and reducing the load on the protocol stack.

[0012] In conjunction with some embodiments of the first aspect, in some embodiments, the client determines a historical synchronization rate, which is related to the amount of data of historically synchronized data and the synchronization duration of historical synchronization; the client determines the first synchronization rate based on the historical synchronization rate.

[0013] In the above embodiments, since different servers have different data receiving capabilities and the types of communication connections established between the client and the server are different, the client can predict the first synchronization rate based on the historical synchronization rate.

[0014] In conjunction with some embodiments of the first aspect, in some embodiments, the client determines the amount of data to be synchronized based on the first synchronization rate and the expected synchronization duration; the client determines the set of files to be synchronized based on the amount of data to be synchronized and the synchronization priority of the multiple file copies.

[0015] In the above embodiment, the client can determine the amount of data to be sent in this synchronization based on the first synchronization rate, and then determine the set of files to be synchronized based on the synchronization priority of multiple file copies.

[0016] In conjunction with some embodiments of the first aspect, in some embodiments, the synchronization data includes dirty data or write operations.

[0017] In conjunction with some embodiments of the first aspect, in some embodiments, the client determines the synchronization information of multiple file copies based on the dirty bit of the page; or, the client determines the synchronization information of multiple file copies based on write operations.

[0018] In the above embodiments, the client needs to traverse the cache to determine the synchronization information of multiple file copies based on dirty bits; if the client determines the synchronization information of multiple file copies based on write operations, it can avoid traversing the cache and reduce the amount of computation.

[0019] In conjunction with some embodiments of the first aspect, in some embodiments, the synchronization information further includes at least one of: the location of dirty pages, the number of dirty pages, the proportion of synchronized data to the file, the most recent modification time, and the most recent synchronization time.

[0020] In the above embodiments, the client must at least determine the synchronization priority of the file copy based on the aging level and the amount of synchronized data, and can also determine the synchronization priority of the file copy based on other parameters in the synchronization information.

[0021] In conjunction with some embodiments of the first aspect, in some embodiments, the lower limit of the first range is greater than or equal to the upper limit of the first range; the synchronization priority of the file copy located in the first range is lower than the synchronization priority of the file copy located in the second range; the file copy with the lower synchronization priority will be synchronized first.

[0022] In the above embodiments, when the lower limit of the first range is greater than or equal to the upper limit of the second range, the file copy in the first range has a higher degree of aging compared to the file copy in the second range. Therefore, a lower synchronization priority is configured so that file copies that have not been synchronized for a long time can be synchronized first.

[0023] In conjunction with some embodiments of the first aspect, in some embodiments, the upper limit of the first range is less than the lower limit of the first range; the synchronization priority of the file copy located in the first range is greater than the synchronization priority of the file copy located in the second range; the file copy with the lower synchronization priority will be synchronized first.

[0024] In the above embodiments, when the upper limit of the first range is less than or equal to the lower limit of the second range, the aging degree of the file copy in the first range is lower than that of the file copy in the second range. Therefore, a higher synchronization priority is configured so that the file copy that has not been synchronized for a long time can be synchronized first.

[0025] In conjunction with some embodiments of the first aspect, in some embodiments, the plurality of file copies includes a first file copy and a second file copy; the aging degree of the first file copy is within the first range; when the aging degree of the first file copy is less than that of the second file copy, the synchronization priority of the first file copy is greater than that of the second file copy; when the aging degree of the first file copy is greater than that of the second file copy, the priority of the first file copy is less than that of the second file copy; the file copy with the lower synchronization priority will be synchronized first.

[0026] In the above embodiments, when the aging degree of the first file copy and the second file copy is within the first range, the synchronization order between the first file copy and the second file copy can be further determined according to the magnitude of the aging degree.

[0027] In conjunction with some embodiments of the first aspect, in some embodiments, when the aging degree of the first file copy is equal to the aging degree of the second file copy, and when the amount of synchronized data of the first file copy is less than the amount of synchronized data of the second file copy, the synchronization priority of the first file copy is lower than the synchronization priority of the second file copy; when the aging degree of the first file copy is equal to the aging degree of the second file copy, and when the amount of synchronized data of the first file copy is greater than the amount of synchronized data of the second file copy, the synchronization priority of the first file copy is greater than the synchronization priority of the second file copy.

[0028] In the above embodiments, when the aging levels of the first file copy and the second file copy are within the first range, and the aging levels of the first file copy and the second file copy are the same, the client determines the synchronization order between the first file copy and the second file copy based on the amount of data of the synchronized data, thereby reducing the average synchronization time of multiple file copies.

[0029] In conjunction with some embodiments of the first aspect, in some embodiments, when the aging level of the first file copy is equal to the aging level of the second file copy, the synchronization priority of the first file copy is equal to the synchronization priority of the second file copy.

[0030] In conjunction with some embodiments of the first aspect, in some embodiments, the plurality of file copies includes a third file copy and a fourth file copy; the aging level of the third file copy is within the second range, and the aging level of the fourth file copy is within the second range; when the amount of synchronized data of the third file copy is less than the amount of synchronized data of the fourth file copy, the synchronization priority of the third file copy is less than the synchronization priority of the fourth file copy; when the amount of synchronized data of the third file copy is greater than the amount of synchronized data of the fourth file copy, the synchronization priority of the third file copy is greater than the synchronization priority of the fourth file copy; the file copy with the lower synchronization priority will be synchronized first.

[0031] In the above embodiments, when the aging levels of the third and fourth file copies are within the second range, the client can prioritize synchronizing files with smaller data volumes, thereby reducing the average synchronization time.

[0032] In a second aspect, embodiments of this application provide an electronic device comprising: one or more processors and a memory; the memory is coupled to the one or more processors and is used to store computer program code, the computer program code including computer instructions, wherein the one or more processors invoke the computer instructions to cause the electronic device to perform the method described in the first aspect and any possible implementation thereof.

[0033] Thirdly, embodiments of this application provide a chip system applied to an electronic device. The chip system includes one or more processors, which are used to invoke computer instructions to cause the electronic device to perform the methods described in the first aspect and any possible implementation thereof.

[0034] Fourthly, embodiments of this application provide a computer program product containing instructions that, when the computer program product is run on an electronic device, cause the electronic device to perform the method described in the first aspect and any possible implementation thereof.

[0035] Fifthly, embodiments of this application provide a computer-readable storage medium including instructions that, when executed on an electronic device, cause the electronic device to perform the method described in the first aspect and any possible implementation thereof.

[0036] It is understood that the electronic device provided in the second aspect, the chip system provided in the third aspect, the computer program product provided in the fourth aspect, and the computer storage medium provided in the fifth aspect are all used to execute the methods provided in the embodiments of this application. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods, and will not be repeated here. Attached Figure Description

[0037] Figure 1A This is a schematic diagram of an example network file system involved in this application;

[0038] Figure 1B This is an exemplary schematic diagram of the write-back mechanism involved in this application;

[0039] Figure 1C This is an exemplary schematic diagram of the dependency graph in the write-back mechanism involved in this application;

[0040] Figure 1D This is an exemplary schematic diagram of a transaction in the write-back mechanism involved in this application;

[0041] Figure 1E This is an exemplary schematic diagram of the write barrier in the write-back mechanism involved in this application;

[0042] Figure 1F This is an exemplary schematic diagram of the persistence mechanism involved in this application.

[0043] Figure 2A and Figure 2B An exemplary schematic diagram of the file write-back synchronization method involved in this application;

[0044] Figure 2C and Figure 2D This is an exemplary schematic diagram of a write-back synchronization method scenario for the implementation documents involved in this application;

[0045] Figure 3 An exemplary schematic diagram of the multi-file synchronization method provided in the embodiments of this application;

[0046] Figure 4A , Figure 4B An exemplary schematic diagram of the client-server communication connection provided in the embodiments of this application;

[0047] Figure 5 An exemplary schematic diagram of the method for determining synchronization information provided in the embodiments of this application;

[0048] Figure 6 An exemplary schematic diagram of a method for determining the number of files to be synchronized provided in an embodiment of this application;

[0049] Figure 7 An exemplary schematic diagram of a method for determining a file or dirty data of a file during synchronization, provided in an embodiment of this application;

[0050] Figure 8 An exemplary schematic diagram of the timeout mechanism provided in the embodiments of this application;

[0051] Figure 9A , Figure 9B An exemplary schematic diagram of a multi-file synchronization scenario provided in the embodiments of this application;

[0052] Figure 10 An exemplary schematic diagram of the hardware structure of the electronic device 100 provided in this application embodiment;

[0053] Figure 11 An exemplary schematic diagram of the software structure of the electronic device 100 provided in the embodiments of this application;

[0054] Figure 12 Another software architecture diagram of the electronic device 100 provided in the embodiments of this application. Detailed Implementation

[0055] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to and includes any or all possible combinations of one or more of the listed items.

[0056] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.

[0057] Network File System (NFS) allows clients to access source files on a server over the network in a manner similar to accessing local files. To ensure data consistency between the client's copy of the source file and the server's copy, synchronization between the client and server is required. Data consistency means that the cached copy of the source file on the client is identical to the data in the source file on the server. Synchronization is a client-initiated process used to achieve data consistency.

[0058] The object of client-side synchronization can be dirty data or a write I / O operation (or simply write operation) that modifies a copy of the source file in the client's cache. For ease of explanation, the object of synchronization is referred to as synchronization data, which can be either dirty data or a write operation.

[0059] Dirty data refers to data that has been modified on the client but has not yet been synchronized to the server; in other words, dirty data is data where the copy of the source file on the client is inconsistent with the source file on the server.

[0060] Among these, client-side synchronization of dirty data can achieve data consistency in the final state; client-side synchronization of write operations can achieve data consistency in the intermediate and final states.

[0061] The final state refers to the state of the data after synchronization is completed; the intermediate state refers to the state of the data changes in the source file and its copy before the final state.

[0062] First, the following section will use data synchronization as an example of a write operation to illustrate the single-file synchronization method.

[0063] Figure 1A This is a schematic diagram of an example network file system involved in this application.

[0064] like Figure 1A As shown, after the client and server establish a communication connection, the server can map the source file to the client's local machine. The client can then operate the virtual file system through system calls, thereby manipulating the source file.

[0065] When a client modifies a source file on the server, the modification operation is transmitted to the server via a remote procedure call (RPC). The server then modifies the source file based on this modification operation, thereby achieving synchronization between the client and the server.

[0066] Obviously, if the transmission rate of the communication connection between the client and the server fluctuates greatly or is low, the source file will be readable and cannot be modified by the client until the server completes the modification based on the modification operation, resulting in a poor user experience.

[0067] To reduce the significant latency between the client and server caused by fluctuations in the transmission rate of the communication connection and improve the user experience, the server can send part or all of the data of the shared file to the client, and the client will store part or all of the data of the shared file in a cache.

[0068] Figure 1B This is an exemplary schematic diagram of the write-back mechanism involved in this application.

[0069] and Figure 1A The difference is that the client can store some or all of the source file data on the server in a local cache and use queues or other data structures to organize all data pages related to the source file copy. This eliminates the need for network access via RPC, reducing the overhead and latency of modifying the source file copy on the client side.

[0070] like Figure 1B As shown, when a client modifies a copy of the source file, a write-back mechanism is triggered. This mechanism divides one or more modification operations into one or more write operations and sends these write operations to the server. Upon receiving these write operations, the server can temporarily suspend processing them and send a response to the client to inform it that the server has received the write operations.

[0071] In this process, one or more write operations ensure that the cached copy of the source file on the client side maintains consistency with the data of the source file on the server side, thereby achieving synchronization. That is, a single file synchronization operation includes one or more write operations.

[0072] After receiving the response, the client can continue modifying its copy of the source file. At some later point, the client can send a request to the server. Upon receiving this request, the server can complete the modification of the local source file based on one or more previously received write operations. At this point, a synchronization between the client and the server is complete.

[0073] Understandably, because it does not require waiting for the server to update the local source file based on write operations, non-blocking synchronization is achieved. During the synchronization process, the client is allowed to modify a copy of the source file, which helps to improve the user experience.

[0074] It is worth noting that the data synchronized in the write-back mechanism may not be a write operation, but rather dirty data from a copy of the source file.

[0075] To further improve the data consistency of the intermediate states in the write-back mechanism and ensure that the data written back is consistent with the data written, a dependency graph can be established to guarantee the data consistency of the intermediate states.

[0076] Figure 1C This is an exemplary schematic diagram of the dependency graph in the write-back mechanism involved in this application.

[0077] like Figure 1CAs shown, each node in the dependency graph corresponds to a write operation and the data involved in that write operation. The order of the arrows indicates the sequential dependency relationship between different write operations. That is, the data pointing to the arrow must be synchronized before the data pointed to by the arrow is synchronized.

[0078] For example, such as Figure 1C As shown, if the data corresponding to node 5 is to be synchronized, it is necessary to ensure that all data that node 5 depends on is synchronized before synchronization. That is, the data corresponding to nodes 1, 2, 3, and 4 need to be synchronized.

[0079] For example, there are two variables on the client: x and y. When the user modifies x, y will automatically change; when the user modifies y, x will not automatically change. For example, when x is modified, the value of y changes to y = x + 5.

[0080] Here, x represents the data corresponding to node 5, and y can be the data corresponding to node 4. The user sequentially modifies the following on the client: first, y is changed to 2, then x is changed to 1. After the modification, x on the client has a value of 1 and y has a value of 6.

[0081] If the client synchronizes modifications to x first, then syncs modifications to y, the data on the server will have both x and y set to 1, resulting in inconsistency with the client's data. However, if, according to the dependency graph, modifications to y are synchronized first, then x, the data on the server will be consistent with the client's data.

[0082] Furthermore, a group of write operations with dependencies can be synchronized as an indivisible transaction. The transaction is the smallest unit of indivisible synchronization. Transaction synchronization can be accomplished through a commit statement, and the data is stored in an in-memory journal.

[0083] Figure 1D This is an exemplary schematic diagram of a transaction in the write-back mechanism involved in this application.

[0084] like Figure 1D As shown, when node 2 depends on node 1 and no node depends on node 2, the write operations of the data corresponding to node 1 and the data corresponding to node 2 can be treated as an indivisible transaction for synchronization.

[0085] Figure 1E This is an exemplary schematic diagram of the write barrier in the write-back mechanism involved in this application.

[0086] To ensure data consistency between the shared file copy on the client and the shared file on the server, client write requests must be completed before cached flush commands are executed. The time interval between two consecutive flush commands is called an epoch. Each flush command can be considered a write barrier.

[0087] like Figure 1E As shown, the order of write operations within a single epoc can vary; however, write operations in different epocs are relatively ordered. For example, the order of write operation 1 and write operation 2 can vary, but write operation 1 must precede write operation 3.

[0088] To handle special circumstances such as memory power failure, the client can also store a copy of the source file in the cache, the location of the copy of the source file in the cache, and the location of the source file on the server in non-volatile storage media such as ROM / flashmemory.

[0089] Figure 1F This is an exemplary schematic diagram of the persistence mechanism involved in this application.

[0090] like Figure 1F As shown, each time a client modifies a copy of the source file in the cache, it can save a copy of the modification operation in non-volatile storage. For example, the client's copy of the source file includes data A, where the value of data A has been modified by the client but has not yet been synchronized. After the client modifies the value of data A, it can save the write operation that modifies data A, the position of data A in the client's cache, and the position of data A in the server's cache in non-volatile storage. If the cache loses power and data is lost, the client can retrieve the copy of the source file from the server again and restore the client's modification operation from the non-volatile storage, thus restoring the state of the copy of the source file on the client before the power failure.

[0091] Figures 1A to 1F The corresponding text description mainly introduces the write-back mechanism when synchronizing a single file. The following describes a file synchronization method involved in this application, and the problems faced by this method when synchronizing multiple files.

[0092] The following is combined Figure 2A , Figure 2B The content shown exemplarily illustrates a file synchronization method related to this application.

[0093] Figure 2A and Figure 2B This is an exemplary schematic diagram of the file write-back synchronization method involved in this application.

[0094] like Figure 2A As shown, the server can share multiple source files, including file 1 and file 2, with the client over the network. After receiving a copy of the source file from the server, the client can store part or all of the source file data in its local cache.

[0095] Due to the limited size of the local cache on the client, when a user browses or modifies file 1, the data in the cache needs to be swapped out and the swapped-out dirty data needs to be synchronized with the server.

[0096] like Figure 2B As shown, if a user browses or modifies file 1 on an electronic device, dirty data for file 1 is generated. The electronic device will store this dirty data in its cache. If the cache is full, some of the dirty data needs to be evicted.

[0097] For example, if the dirty data to be eliminated is the dirty data of file 2, then other parts or all of the dirty data of file 2 can be synchronized together, and the dirty data that has been successfully synchronized can be deleted after successful synchronization.

[0098] If the data transmission rate of the communication connection between the client and the server is low when synchronizing dirty data in file 2, or if the amount of old dirty data in file 2 is large, it will cause network congestion, reduce the synchronization time of subsequent files, and thus affect the synchronization of subsequent files.

[0099] For example, if the obsolete dirty data is from file 1, then other old dirty data from file 1 can be synchronized along with it. Similarly, if the network transmission rate between the client and server is low, or if the amount of dirty data in file 1 is large, it will cause network congestion, reduce the synchronization time of subsequent files, and thus affect the synchronization of subsequent files.

[0100] Figure 2C and Figure 2D This is an exemplary schematic diagram of a write-back synchronization method scenario for the implementation documents involved in this application.

[0101] Because the data transmission rate of the communication connection between the client and the server is time-varying, the synchronization time will be different for the same amount of dirty data when the client performs the same data synchronization at different times.

[0102] like Figure 2C As shown, when the client starts synchronization at synchronization time 1 and completes the synchronization at synchronization time 2, the time taken is synchronization time 1; when the client starts synchronization at synchronization time 3 and completes the synchronization at synchronization time 4, the time taken is synchronization time 2.

[0103] Because the data transmission rate of the communication connection between the client and the server is higher between synchronization time 1 and synchronization time 2, and lower between synchronization time 3 and synchronization time 4, the synchronization duration 1 is shorter than the synchronization duration 2.

[0104] Furthermore, in most cases, the client often needs to synchronize multiple files with the server. In this situation, the file write-back synchronization method involved in this application can prioritize synchronizing files that have been evicted from the cache by the client, or randomly select files or dirty data from files for priority synchronization. However, when the size of the evicted file or the amount of dirty data is large, the caching time of that file is longer, increasing the synchronization time of other subsequent files.

[0105] like Figure 2D As shown, the client starts synchronizing files 1, 2, and 3 to the server sequentially at second 0. The amount of dirty data in file 1 is 1020kb, in file 2 it is 500kb, and in file 3 it is 460kb. The network transfer rate between the client and server is 200kb / s.

[0106] First, at 5.1 seconds, the client sends out all the dirty data of file 1, completing the synchronization of file 1.

[0107] Secondly, for file 2, if file 2 needs to be synchronized before 5.1 seconds, it must wait for file 1 to be synchronized before data transmission can begin. For example, at 0 seconds, the client starts synchronizing file 1, but at 5.1 seconds, it begins transmitting the dirty data of file 2. At 7.6 seconds, the client sends out all the dirty data of file 2, completing the synchronization of file 2.

[0108] Secondly, for file 3, if it needs to be synchronized before 7.6 seconds, it must wait for file 1 and file 2 to synchronize before data transmission can begin. For example, at 0 seconds, the client starts synchronizing file 3, but at 7.6 seconds, it begins transmitting the dirty data of file 3. At 9.9 seconds, the client sends out all the dirty data of file 3, completing the synchronization of file 2.

[0109] It is understandable that the files being synchronized in the file write-back synchronization method involved in this application are random, resulting in a longer synchronization time for subsequent files. Furthermore, if the network transmission rate is low and the file containing a large amount of data is being synchronized, it will significantly increase the synchronization time for subsequent files.

[0110] To reduce the average synchronization time of multiple files, this application provides a method for synchronizing multiple files. The method includes: first, the client predicts the current synchronization rate based on historical synchronization rates; second, the client determines the priority of each file to be synchronized based on the predicted synchronization rate and the synchronization information of copies of the source files; finally, the client determines a set of files to be synchronized based on the priorities of the files and performs synchronization.

[0111] For ease of description, "file" refers to a copy of the source file on the client.

[0112] The following is an exemplary description of the multi-file synchronization method provided in the embodiments of this application.

[0113] Figure 3 This is an exemplary schematic diagram of a multi-file synchronization method provided in an embodiment of this application.

[0114] like Figure 3 As shown, the multi-file synchronization method provided in this application includes:

[0115] S301: The server and client establish a communication connection.

[0116] Specifically, the client and server establish a communication connection.

[0117] The server is an electronic device that provides shared files to the client, and the client is an electronic device that receives shared files from the server.

[0118] The client / server can be a terminal device, such as a mobile phone, tablet computer, virtual reality terminal device, augmented reality terminal device, wireless terminal in industrial control, wireless terminal in autonomous driving, wireless terminal in telemedicine, wireless terminal in smart grid, wireless terminal in transportation safety, wireless terminal in smart city, wireless terminal in smart home, wearable device, vehicle-mounted device, etc.

[0119] The server can serve the client, providing source files and storing client data. It can also be called a server.

[0120] It is worth noting that a client can be either the endpoint that initiates the communication connection or the endpoint that receives the communication connection.

[0121] The type of communication connection established between the client and the server depends on the capabilities of the protocol stacks on both the client and the server. When both the client and the server's protocol stacks support multipath transport protocols such as MPTCP and Multipath Quick UDP Internet Connection (MPQUIC), multiple paths for data transmission can exist between the client and the server.

[0122] The following is combined Figure 4A , Figure 4B The content shown is used as an example to illustrate the communication connection between the client and the server.

[0123] Figure 4A , Figure 4B This is an exemplary schematic diagram of a client-server communication connection provided in an embodiment of this application.

[0124] like Figure 4A As shown, the client can be a mobile terminal, such as a mobile phone. The mobile phone communicates with the server through both a base station and a router. For example, the base station assigns the mobile phone IP address IP1, the router assigns the mobile phone IP address IP2, and the mobile phone's source port is 80. The server's IP address is IP3, and the server's destination port is 1314. In this case, the mobile phone can communicate with the server through a first physical path: (IP1, 80, IP3, 1314) and a second physical path: (IP2, 80, IP3, 1314).

[0125] In near-field scenarios, the client can also establish a communication connection with the server through near-field communication services. These near-field communication services can include Bluetooth, Apple Wireless Direct Link (AWDL), HiLink, ZigBee, etc.

[0126] like Figure 4B As shown, the client can be a PC, and the server can be a mobile phone. The mobile phone establishes a connection with the PC via Bluetooth and a router, respectively.

[0127] Understandably, depending on the capabilities of the protocol stack on the client and server, the client and server can establish communication connections in a variety of different ways.

[0128] S302: The server shares source files with the client.

[0129] Specifically, after establishing a communication connection between the client and the server, the server sends a copy of the source file to the client to share the source file.

[0130] In this scenario, the server can share source files with the client in response to a client's request, or the sharing can occur automatically after a communication connection is established.

[0131] S303: The client stores a copy of the source file it has obtained in the cache.

[0132] Specifically, after receiving a copy of the source file from the server, the client can store the entire copy of the source file in a cache, such as in the page buffer of RAM, or in other random access storage media or non-volatile storage media. Alternatively, after receiving a copy of the source file from the server, the client can store a portion of the copy of the source file in a cache, and the remaining portion can be stored in non-volatile storage media on the client, such as ROM / flash memory.

[0133] If a portion of the source file's copy is stored in the cache, this portion of the source file's copy could be data from a copy of the source file that is frequently modified by the client.

[0134] S304: When a client modifies a copy of the source file, determine the synchronization information.

[0135] Specifically, when a client modifies a source file, it can determine / update the synchronization information of the copy of that source file. This synchronization information includes: the location of dirty pages, the number of dirty pages, whether the file is dirty, the proportion of dirty data in the file, the last modification time, the last synchronization time, and the amount of data involved in the write operation.

[0136] The client can determine the modified file and the modified data based on the write operation. Alternatively, the client can determine whether a page is dirty based on its dirty bit flag; dirty pages contain dirty data.

[0137] A write operation can include: the file to be written to, the page in the file to be modified, and the data to be modified. For example, the format of a write operation can be `write(file, buf, &pos)`. The input parameters for the write operation can include the file `file`, the data to be modified `buf`, and the position of the modified data `&pos`. The position of the data `&pos` determines the page to be modified.

[0138] The following is combined Figure 5 The content shown in Table 1 illustrates, for example, a method for determining synchronization information.

[0139] Figure 5 This is an exemplary schematic diagram of a method for determining synchronization information provided in an embodiment of this application.

[0140] like Figure 5 As shown, when a client performs a write operation on a copy of the source file in the cache, it can determine the file being modified and the location of the modified data within the file's page through the write operation.

[0141] Table 1 is an exemplary schematic table of file dirty data statistics provided in the embodiments of this application.

[0142] Table 1

[0143]

[0144] The client's cache contains copies of the source files: File 1, File 2, and File 3. File 1 contains 2 dirty pages, 8KB of dirty data (28.57% dirty data percentage), with a last modification time of T1 and a last synchronization time of T2. File 2 contains 4 dirty pages, 16KB of dirty data (50% dirty data percentage), with a last modification time of T3 and a last synchronization time of T4. File 3 contains 1 dirty page, 4KB of dirty data (20% dirty data percentage), with a last modification time of T5 and a last synchronization time of T6.

[0145] Alternatively, the client can iterate through the dirtybit flags of the pages in the cache to determine the dirty pages of each file.

[0146] Understandably, when modifying a copy of the source file, the client can determine the synchronization information of the copy of the source file based on the modification operation.

[0147] S305: The client determines the synchronization priority of multiple files based on synchronization information.

[0148] Specifically, a client can use various methods to determine the synchronization priority of multiple files based on synchronization information. The client can choose different methods to determine file synchronization priorities based on different criteria.

[0149] Optionally, the client can group the files to be synchronized on the client side based on parameters such as the proportion of the synchronized data to the original file copy, the file modification frequency, and the most recent synchronization time, before determining the file synchronization priority. The synchronization order between groups can be determined according to user selection or client-preset rules, while the file synchronization order within a group is determined by the file synchronization priority within that group.

[0150] For example, files can be grouped according to their most recent modification time. Files modified within the last 10 seconds are grouped into the first group, those modified between 10 and 20 seconds into the second group, those modified between 20 and 30 seconds into the third group, and so on. The synchronization priority of files within each group can be determined as follows. Another example is grouping files by modification frequency: files modified 0-5 times within 10 seconds are grouped into the first group, those modified 6-10 times within 10 seconds into the second group, those modified 11-15 times within 10 seconds into the third group, and so on. Yet another example is grouping files based on multiple parameters.

[0151] The following section details the methods for determining file synchronization priority:

[0152] Firstly, the client can determine the synchronization priority of multiple files based on their aging status.

[0153] The client can determine the aging level of the source file copy in the cache, where the aging level can be related to the file's most recent synchronization time.

[0154] For example, Age degree =(T now -T rec k1, Age degree T represents the aging degree of the copy of the source file. now For the present moment, T rec The most recent synchronization time of the copy of the source file, k1 is the aging factor of 1, (T now -T rec This represents the duration during which the source file copy has not been synchronized. The aging factor can vary between different files. For example, files frequently modified by users or used by multiple users can have a higher aging factor.

[0155] For example, Where T1 is the preset aging time threshold 1.

[0156] For example, Where T2 is the preset aging time threshold 1.

[0157] Where k2 is the aging coefficient 2.

[0158] Once the client determines the aging status of the source file's copy in the cache, it can determine the synchronization priority of that file.

[0159] For example, a file's synchronization priority is equal to a negative aging level. The lower the file's synchronization priority value, the faster it is synchronized.

[0160] When multiple files have the same aging level or the same synchronization priority, the client can determine the synchronization order within the multiple files based on the amount of data to be synchronized. For example, the file with the smaller amount of data to be synchronized will be synchronized first.

[0161] It is understandable that prioritizing the synchronization of files with high aging levels can prevent the client from always synchronizing newly generated files while ignoring files modified before synchronization. This results in a lower aging level for the files with the highest aging level on the client, thus helping to keep the data gap between the client and the server within a small range.

[0162] Secondly, the client can determine the synchronization priority of multiple files based on the amount of data to be synchronized or the proportion of the amount of data to the copy of the source file.

[0163] like Figure 5 As shown in Table 1, the client can determine the amount of data to be synchronized for the copy of the source file, and thus determine the synchronization priority of multiple files.

[0164] For example, a file synchronization priority is equal to the negative amount of synchronized data in the file, or the negative proportion of synchronized data in the source file's copy. Specifically, for example, when the synchronized data is dirty data, the file synchronization priority is equal to the negative amount of dirty data in the source file's copy or the proportion of negative dirty data * 100. When the synchronized data is a write operation, the file synchronization priority is equal to the negative amount of write operation data in the source file's copy or the proportion of synchronized data in the source file's copy * 100.

[0165] Understandably, when a client determines the synchronization priority of multiple files based on the amount of data to be synchronized or the proportion of the data to the original file copy, it will prioritize synchronizing files with larger amounts of data or files whose data to the original file copy is larger.

[0166] Understandably, considering that files with larger data volumes are more likely to be frequently modified by users, the client can prioritize synchronizing files with larger data volumes to improve the user experience.

[0167] It's worth noting that when synchronizing dirty data, using the amount of data to be synchronized, rather than the frequency of file modifications, to determine the priority of file synchronization is more robust. For example, if a user modifies variable Z in file 1 to 1, 3, 5, 1, in this case, the amount of data to be synchronized for file 1 is 0, so file 1 does not need to be synchronized, or it does not need to be synchronized first. However, if the priority of file synchronization is determined based on the frequency of file modifications, file 1 will be synchronized first.

[0168] Third, the client can determine the synchronization priority of multiple files based on the amount of data and the degree of aging of the synchronized data.

[0169] For example,

[0170] Where T2 is the preset aging time threshold 2.

[0171] or,

[0172] The synchronization coefficient can be related to the type of data being synchronized; that is, the synchronization coefficient for dirty data differs from the synchronization coefficient for write operations. For example, if the synchronized data for file copy 1 is dirty, the synchronization coefficient for file copy 1 is 1; if the synchronized data for file copy 2 is write operations, the synchronization coefficient is 0.9. Alternatively, if the synchronized data for file copy 2 is write operations, the synchronization coefficient is 1.1.

[0173] When the data volume multiplied by the synchronization coefficient of multiple files is the same, or when the synchronization priority of multiple files is the same, the client can determine the synchronization order of multiple files based on the aging level.

[0174] For example,

[0175] or,

[0176] Where T3 is the preset aging time threshold of 3.

[0177] For example,

[0178] For example,

[0179] Where T4 is the preset aging time threshold of 4.

[0180] Understandably, clients can also determine file synchronization priorities in various ways, which will not be limited here.

[0181] It is worth noting that the file synchronization priority provided in this application embodiment, in most cases, prioritizes smaller files for synchronization, thus synchronizing them first. Specifically, when the aging level of a file is greater than a threshold, it is synchronized with files whose aging level is lower than the threshold first. This avoids the situation where the client always prioritizes synchronizing newly generated data, causing delays in synchronizing files with higher aging levels, which leads to inconsistencies between the client and the data segment, thus improving the user experience.

[0182] It is worth noting that, in the embodiments of this application, the method for determining the synchronization priority of a file is related to the way the client synchronizes the file. For example, when the client synchronizes dirty data, in most cases, the smaller the amount of dirty data in the file, the higher the priority. Similarly, when the client synchronizes write operations, in most cases, the smaller the amount of write operations, the higher the priority.

[0183] Alternatively, the client can determine the synchronization priority of multiple files based on the amount of data to be synchronized and / or the degree of aging.

[0184] For example,

[0185] T5 is the preset aging time threshold of 5.

[0186] For example,

[0187] Where T6 is the preset aging time threshold of 6, and F (the amount of synchronized data, Age) is the aging time threshold of 6. degree ) is a preset function that outputs the file's synchronization priority.

[0188]

[0189] Where T7 is the preset aging time threshold 7 and T8 is the preset aging time threshold 8.

[0190] It is worth noting that after each synchronization of a copy of the source file, the client needs to update the file synchronization information.

[0191] S306: The client determines the set of files to be synchronized based on the file synchronization priority and synchronization rate.

[0192] Specifically, before synchronization, the client predicts the current synchronization rate based on the synchronization rates of one or more past time slices. The client can then determine the amount of data to be synchronized in a single synchronization based on this synchronization rate, and further determine the set of files to be synchronized based on the amount of data and the file synchronization priorities.

[0193] The synchronization rate can be the transmission rate of synchronization data between the client and the server, the rate at which the client sends synchronization data, or the rate at which the server receives synchronization data.

[0194] Optionally, in some embodiments of this application, the communication connection between the client and the server can be classified based on the synchronization rate, and the amount of synchronized data can be determined according to the level of the communication connection.

[0195] Table 2 is an exemplary schematic table of communication connection hierarchy provided in the embodiments of this application.

[0196] Table 2

[0197] Level of communication connection Synchronization rate The amount of data to be synchronized Grade 1 / Excellent greater than 500KB / s Synchronization rate * desired synchronization duration Grade 2 / Excellent 400-500KB / s Synchronization rate * desired synchronization duration Grade 3 / Good 350-400KB / s Synchronization rate * desired synchronization duration Grade 4 / Good 300-350KB / s Synchronization rate * desired synchronization duration Level 5 / Medium 150-300KB / s Synchronization rate * desired synchronization duration Level 6 / Poor 75-150KB / s Synchronization rate * desired synchronization duration Grade 7 / Poor 0-75KB / s Synchronization rate * desired synchronization duration

[0198] As shown in Table 2, the client can determine the communication connection level based on the synchronization rate and the amount of data to be synchronized in one synchronization. The expected synchronization duration can be a fixed value, or it can be related to the communication connection level, or it can be related to the type of file being synchronized.

[0199] For example, the higher the level of the communication connection (the smaller the value), the lower the expected synchronization time can be.

[0200] For example, the expected synchronization time for files that users modify frequently can be lower than the expected synchronization time for files that users modify infrequently.

[0201] Optionally, in some embodiments of this application, considering that the predicted synchronization rate will inevitably have some errors, the amount of synchronized data can be directly determined based on the communication connection level. For example, when the communication connection is level 1, the client can directly determine that the amount of synchronized data is 50KB, and when the communication connection is level 2, the client can directly determine that the amount of synchronized data is 45KB, etc.

[0202] The following is combined Figure 6 The content shown exemplifies a method for a client to determine the set of files to be synchronized.

[0203] Figure 6 An exemplary schematic diagram of a method for determining the number of files to be synchronized, provided in an embodiment of this application.

[0204] like Figure 6 As shown, methods for determining the number of files to be synchronized may include:

[0205] S601: Client initializes the synchronization queue.

[0206] Specifically, in step S305, the client has determined the synchronization priority of different files. The client can initialize the synchronization queue using various data structures such as queues, arrays, and min-heaps, with higher-priority files being prioritized by the client.

[0207] S602: The client determines the amount of data to be synchronized in one synchronization.

[0208] Specifically, the client can determine the amount of data to be synchronized in a single synchronization based on the synchronization rate.

[0209] S603: The client adds the file with the highest synchronization priority to the set of files to be synchronized.

[0210] Specifically, the client retrieves the highest-priority file from the synchronization queue in sequence, adds the highest-priority file to the set of files to be synchronized, and updates the synchronization queue.

[0211] S604: The sum of the data volume of the files in the set of files to be synchronized is less than or equal to the data volume of a single synchronization.

[0212] Specifically, the client determines whether the sum of dirty data in the files to be synchronized is less than the amount of data to be synchronized in one synchronization. If yes, proceed to step S603; otherwise, proceed to step S605.

[0213] It is worth noting that if the synchronization data sent by the client during subsequent steps is a write operation, the client will determine whether the sum of the write operations of the files to be synchronized is less than the amount of synchronization data.

[0214] S605: Remove the last added file from the set of files to be synchronized.

[0215] Specifically, when the amount of data in the set of files to be synchronized exceeds the amount of data in a single synchronization, the client will remove the last file added from the set of files to be synchronized.

[0216] Optionally, in some embodiments of this application, considering that there may be some error in the amount of synchronized data, the client may not remove the last added file from the set of files to be synchronized.

[0217] The following is combined Figure 7 The content shown is a specific example. Figure 6 The method for determining the set of files to be synchronized.

[0218] Figure 7 This is an exemplary schematic diagram of a method for determining a set of files to be synchronized, provided in an embodiment of this application.

[0219] like Figure 7 As shown, the client can use a min-heap to determine the set of files to be synchronized, where the value of each heap node in the min-heap is the synchronization priority of different files.

[0220] The client can continuously select the root node of the min-heap until the sum of the data in the set of files to be synchronized exceeds the amount of data synchronized in a single synchronization. Alternatively, the client can continuously select the file corresponding to the root node of the min-heap for synchronization until the sum of the data in the set of files to be synchronized exceeds the amount of data synchronized in the first synchronization after the next addition of synchronized file data.

[0221] For example, the client determines that the amount of data synchronized in one synchronization is 45KB. Specifically, the amount of data synchronized for a file with a synchronization priority of -5 is 15KB, the amount of data synchronized for a file with a synchronization priority of -2 is 28KB, the amount of data synchronized for a file with a synchronization priority of 12 is 30KB, and the amount of data synchronized for a file with a synchronization priority of 16 is 35KB.

[0222] In this case, the client can choose file 1 with a synchronization priority of -5, file 2 with a synchronization priority of -2, and file 3 with a synchronization priority of -28 as the file to be synchronized. That is, file 1, file 2, and file 3 constitute the set of files to be synchronized. Alternatively, the client can choose file 1 with a synchronization priority of -5 and file 2 with a synchronization priority of -2 as the file to be synchronized. That is, file 1 and file 2 constitute the set of files to be synchronized.

[0223] S307: The client sends a synchronization request to the server to synchronize.

[0224] Specifically, after determining the set of files to be synchronized, the client can send the synchronization data of the files in the set to the server in order of synchronization priority.

[0225] The client can periodically synchronize with the server. For example, the synchronization period can be a pre-configured fixed threshold, or it can vary based on the synchronization rate and communication connection level determined by the client in step S306. For instance, when the synchronization rate is high or the communication connection level is high, the synchronization period can be reduced, increasing the synchronization frequency. For example, when the communication connection level is 1, the synchronization period is 0.02s; when the communication connection level is 2-4, the synchronization period is 0.1s; and when the communication connection level is 5-7, the synchronization period is 0.3s.

[0226] The client can synchronize data once a certain percentage of the cached data has been stored. For example, the client can synchronize data when the copy of the source file occupies 80% of the cache.

[0227] In this context, when a client is synchronizing multiple files, the synchronization of a single file can utilize a write-back mechanism. For details on write-back mechanisms, please refer to [link / reference needed]. Figure 1B , Figure 1C , Figure 1D , Figure 1E , Figure 1F The corresponding textual descriptions will not be repeated here.

[0228] Optionally, in some embodiments of this application, the client may also be configured with a timeout mechanism to cope with network jitter. For example, if the synchronization duration exceeds a preset threshold, synchronization is paused, and a heartbeat detection packet is sent to test the data transmission rate of the communication connection between the client and the server.

[0229] Figure 8 This is an exemplary schematic diagram of the timeout mechanism provided in the embodiments of this application.

[0230] During synchronization, the client can determine the synchronization duration based on the protocol followed by the communication connection between the client and the server. For example, if the communication connection between the client and the server follows the TCP protocol, the client sends an IP packet carrying dirty data of the file, and then determines the synchronization duration based on the time difference between the client receiving the ACK packet from the server.

[0231] like Figure 8 As shown, synchronization times out when the synchronization duration exceeds the synchronization duration threshold. At this point, the client pauses synchronization, meaning it stops sending data to the server, and sends a heartbeat detection packet to the server. This heartbeat detection can also be called a disconnection detection. If the client determines that the communication connection has been restored, synchronization continues; if the communication connection has not been restored, the heartbeat detection packet is resent.

[0232] Next, we will introduce a scenario in which a client implements the multi-file synchronization method provided in the embodiments of this application.

[0233] Firstly, the multi-file synchronization method provided in the embodiments of this application can reduce the average synchronization time in the client cache.

[0234] The client's cache contains N copies of the source file, where N is an integer greater than 2. The synchronization times (synchronization time may not equal synchronization duration; synchronization time = file size or amount of dirty data in the file / synchronization rate) of the synchronization data for these N source file copies are t1, t2, ..., t3, respectively. N .

[0235] If the files synchronized using the single-file synchronization method are in the order from file 1 to file N, and the synchronization times for the copies of these N source files are M1, M2, ..., M, respectively... N .

[0236] The synchronization time for the copy of the i-th source file is:

[0237] Therefore, the average synchronization time for the single-file synchronization method is

[0238] The multi-file synchronization method provided in this application determines the file synchronization priority based on the amount of synchronized data. The more synchronized data a file has, the lower its synchronization priority.

[0239] The client determines the synchronization order of files based on the established file synchronization priority: file N to file 1.

[0240] The synchronization time for the copy of the i-th source file is:

[0241] Therefore, the average synchronization time for the multi-file synchronization method is

[0242] Since, when the transmission rate of the communication connection between the client and the server remains constant or changes little, the synchronization time for a file with a smaller amount of data will necessarily be less than the synchronization time for a file with a larger amount of data. Therefore, T′ avg ≤T avg .

[0243] Furthermore, while reducing the synchronization time, the multi-file synchronization method provided in this application embodiment does not prioritize synchronizing files with low aging levels. This avoids the situation where the client always prioritizes synchronizing newly generated synchronization data, causing delays in synchronizing files with high aging levels, which leads to inconsistencies between the client and the data segment and improves the user experience.

[0244] Secondly, in combination Figure 2D , Figure 9A The content shown in this application describes a multi-file synchronization method that can reduce the average synchronization time in the client cache.

[0245] like Figure 2D As shown, the data size of the synchronized data in file 1 is 1020KB, the data size of the synchronized data in file 2 is 500KB, and the data size of the synchronized data in file 3 is 460KB.

[0246] The client can determine that file 1 has the lowest synchronization priority, file 2 has the second lowest synchronization priority, and file 3 has the lowest synchronization priority. Based on the determined synchronization priority, the client can then synchronize file 3, file 2, and file 1 in that order.

[0247] Figure 9A , Figure 9B This is an exemplary schematic diagram of a multi-file synchronization scenario provided in an embodiment of this application.

[0248] like Figure 9AAs shown, the client starts synchronizing files 1, 2, and 3 sequentially with the server at second 0. At second 2.3, the client sends out all the synchronization data for file 3, completing the synchronization of file 3. The client then starts transmitting synchronization data for file 2 at second 2.3, and at second 4.8, sends out all the synchronization data for file 2, completing the synchronization of file 2. Again, the client starts transmitting synchronization data for file 2 at second 4.8, and at second 9.9, sends out all the synchronization data for file 3, completing the synchronization of file 3.

[0249] It is obvious. Figure 2D When synchronizing three files using the single-file synchronization method shown, the average synchronization time is (9.9+7.6+5.1) / 3 = 7.53 seconds; when synchronizing three files using the multi-file synchronization method provided in this application embodiment, the average synchronization time is (9.9+4.8+2.3) / 3 = 5.67 seconds.

[0250] The multi-file synchronization method provided in this application also considers aging. For example... Figure 9B As shown, the client's cache contains files 1, 2, 3, 4, 5, and 6. The synchronized data size for file 1 is 1020KB, for file 2 it is 500KB, for file 3 it is 460KB, for file 4 it is 860KB, for file 5 it is 350KB, and for file 6 it is 860KB.

[0251] When the client implements the multi-file synchronization method of this application, it can rely on... Determine the file synchronization priority. T3 equals 10.

[0252] After implementing the multi-file synchronization method of this application, the priority from low to high (synchronized first, then last) of the files is as follows: File 1, File 5, File 3, File 2, File 6, and File 4. Among them, File 6 and File 4 have the same amount of data to be synchronized, and their aging levels are both below the aging threshold. The client can synchronize File 6, which has a smaller amount of data, first, and then synchronize File 4, which has a larger amount of data.

[0253] It is worth noting that the synchronization priority of the file can also be determined according to other methods involved in step S305.

[0254] Next, the software and hardware structures of the client and server provided in the embodiments of this application will be introduced.

[0255] Both the client and the server can be the electronic device 100 mentioned below.

[0256] Figure 10This is an exemplary schematic diagram of the hardware structure of the electronic device 100 provided in the embodiments of this application.

[0257] Electronic device 100 may be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, as well as cellular phone, personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, in-vehicle device, smart home device and / or smart city device. The embodiments of this application do not impose any special restrictions on the specific type of electronic device.

[0258] Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0259] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0260] Processor 110 may include one or more processing units, such as application processors (APs), modem processors, graphics processing units (GPUs), image signal processors (ISPs), controllers, video codecs, digital signal processors (DSPs), baseband processors, and / or neural network processing units (NPUs). These different processing units may be independent devices or integrated into one or more processors.

[0261] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.

[0262] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0263] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0264] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple I2C buses. The processor 110 can couple to the touch sensor 180K, charger, flash, camera 193, etc., through different I2C bus interfaces. For example, the processor 110 can couple to the touch sensor 180K through the I2C interface, enabling the processor 110 and the touch sensor 180K to communicate through the I2C bus interface, thereby realizing the touch function of the electronic device 100.

[0265] The I2S interface can be used for audio communication. In some embodiments, the processor 110 may include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to enable communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the I2S interface to enable the function of answering phone calls through a Bluetooth headset.

[0266] The PCM interface can also be used for audio communication, sampling, quantizing, and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via the PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface, enabling the function of answering phone calls through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0267] The UART interface is a universal serial data bus used for asynchronous communication. This bus can be a bidirectional communication bus. It converts the data to be transmitted between serial and parallel communication. In some embodiments, the UART interface is typically used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 via the UART interface to implement Bluetooth functionality. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the UART interface to enable music playback through Bluetooth headphones.

[0268] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI) and a display serial interface (DSI). In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to enable the electronic device 100 to capture images. The processor 110 and the display screen 194 communicate via the DSI interface to enable the electronic device 100 to display images.

[0269] The GPIO interface can be configured via software. It can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 to a camera 193, a display screen 194, a wireless communication module 160, an audio module 170, a sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0270] USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge electronic device 100, and can also be used for data transfer between electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.

[0271] It is understood that the interface connection relationships between the modules illustrated in the embodiments of the present invention are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.

[0272] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.

[0273] The power management module 141 connects the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, internal memory 121, display screen 194, camera 193, and wireless communication module 160, etc. The power management module 141 can also monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage current, impedance). In some other embodiments, the power management module 141 may also be located within the processor 110. In other embodiments, the power management module 141 and the charging management module 140 may be located in the same device.

[0274] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.

[0275] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.

[0276] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.

[0277] The modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs sound signals through audio devices (not limited to speaker 170A, receiver 170B, etc.) or displays images or videos through the display screen 194. In some embodiments, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor 110 and may be housed in the same device as the mobile communication module 150 or other functional modules.

[0278] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.

[0279] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, enabling electronic device 100 to communicate with networks and other devices via wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technologies, etc. The GNSS may include the Global Positioning System (GPS), the Global Navigation Satellite System (GLONASS), the BeiDou Navigation Satellite System (BDS), the Quasi-Zenith Satellite System (QZSS), and / or satellite-based augmentation systems (SBAS).

[0280] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0281] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.

[0282] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.

[0283] The ISP (Image Signal Processor) is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can also perform algorithmic optimization of image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.

[0284] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.

[0285] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when electronic device 100 selects a frequency, the DSP can perform Fourier transforms on the frequency energy.

[0286] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. Thus, electronic device 100 can play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0287] An NPU (Neural Processing Unit) is a computational processor for neural networks (NNs). By borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can rapidly process input information and continuously learn on its own. NPUs enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.

[0288] Internal memory 121 may include one or more random access memory (RAM) and one or more non-volatile memory (NVM).

[0289] Random access memory can include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM, for example, fifth generation DDR SDRAM is generally called DDR5 SDRAM), etc.

[0290] The client's cache can be located in random access memory.

[0291] Non-volatile memory can include disk storage devices and flash memory.

[0292] Flash memory can be classified according to its operating principle, including NOR FLASH, NAND FLASH, 3D NAND FLASH, etc.; according to the level of the storage cell, including single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), quad-level cell (QLC), etc.; and according to the storage specification, including universal flash storage (UFS) and embedded multimedia card (eMMC), etc.

[0293] The random access memory can be directly read and written by the processor 110. It can be used to store executable programs (such as machine instructions) of the operating system or other running programs, as well as user and application data.

[0294] Non-volatile memory can also store executable programs and user and application data, and can be pre-loaded into random access memory for direct reading and writing by the processor 110.

[0295] The external memory interface 120 can be used to connect to external non-volatile memory, thereby expanding the storage capacity of the electronic device 100. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to perform data storage functions. For example, music, video, and other files can be stored in the external non-volatile memory.

[0296] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.

[0297] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.

[0298] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.

[0299] The receiver 170B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a telephone call or voice message, the receiver 170B can be brought close to the ear to listen to the voice.

[0300] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. Electronic device 100 may have at least one microphone 170C. In some embodiments, electronic device 100 may have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 100 may also have three, four, or more microphones 170C, which can collect sound signals, reduce noise, identify the sound source, and perform directional recording, etc.

[0301] The 170D headphone jack is used to connect wired headphones. The 170D headphone jack can be a USB 130 interface or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, a CTIA (Cellular Telecommunications Industry Association of the USA) standard interface.

[0302] Pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. In some embodiments, pressure sensor 180A can be disposed on display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, and capacitive pressure sensors. A capacitive pressure sensor may include at least two parallel plates with conductive material. When force is applied to pressure sensor 180A, the capacitance between the electrodes changes. Electronic device 100 determines the pressure intensity based on the change in capacitance. When a touch operation is applied to display screen 194, electronic device 100 detects the intensity of the touch operation based on pressure sensor 180A. Electronic device 100 can also calculate the touch position based on the detection signal from pressure sensor 180A. In some embodiments, touch operations applied to the same touch position but with different touch operation intensities can correspond to different operation commands. For example, when a touch operation with an intensity less than a first pressure threshold is applied to the SMS application icon, a command to view an SMS is executed. When a touch operation with an intensity greater than or equal to the first pressure threshold is applied to the SMS application icon, a command to create a new SMS is executed.

[0303] The gyroscope sensor 180B can be used to determine the motion attitude of the electronic device 100. In some embodiments, the gyroscope sensor 180B can determine the angular velocity of the electronic device 100 about three axes (i.e., the x, y, and z axes). The gyroscope sensor 180B can be used for image stabilization. For example, when the shutter is pressed, the gyroscope sensor 180B detects the angle of the shake of the electronic device 100, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to counteract the shake of the electronic device 100 by moving in the opposite direction, thus achieving image stabilization. The gyroscope sensor 180B can also be used in navigation and motion-sensing game scenarios.

[0304] The barometric pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates altitude using the air pressure value measured by the barometric pressure sensor 180C to assist in positioning and navigation.

[0305] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip cover. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover using the magnetic sensor 180D. Then, based on the detected opening and closing state of the cover or the flip cover, features such as automatic flip unlocking can be set.

[0306] The 180E accelerometer can detect the magnitude of acceleration of electronic device 100 in various directions (typically three axes). When electronic device 100 is stationary, it can detect the magnitude and direction of gravity. It can also be used to identify the posture of electronic devices and applied to applications such as screen orientation switching and pedometers.

[0307] A distance sensor 180F is used to measure distance. Electronic device 100 can measure distance via infrared or laser. In some embodiments, during a shooting scene, electronic device 100 can utilize the distance sensor 180F to measure distance for rapid focusing.

[0308] The proximity sensor 180G may include, for example, a light-emitting diode (LED) and a light detector, such as a photodiode. The LED may be an infrared LED. The electronic device 100 emits infrared light outward through the LED. The electronic device 100 uses the photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 may use the proximity sensor 180G to detect when a user holds the electronic device 100 close to their ear for a call, so as to automatically turn off the screen to save power. The proximity sensor 180G can also be used in holster mode and pocket mode for automatic unlocking and locking of the screen.

[0309] The ambient light sensor 180L is used to sense the brightness of ambient light. The electronic device 100 can adaptively adjust the brightness of the display screen 194 based on the sensed ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also work with the proximity sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.

[0310] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can utilize the characteristics of the collected fingerprints to achieve fingerprint unlocking, accessing application locks, taking photos with fingerprints, answering calls with fingerprints, etc.

[0311] Temperature sensor 180J is used to detect temperature. In some embodiments, electronic device 100 uses the temperature detected by temperature sensor 180J to execute a temperature handling strategy. For example, when the temperature reported by temperature sensor 180J exceeds a threshold, electronic device 100 performs thermal protection by reducing the performance of a processor located near temperature sensor 180J to reduce power consumption. In other embodiments, when the temperature is below another threshold, electronic device 100 heats battery 142 to prevent abnormal shutdown of electronic device 100 due to low temperature. In still other embodiments, when the temperature is below yet another threshold, electronic device 100 boosts the output voltage of battery 142 to prevent abnormal shutdown due to low temperature.

[0312] Touch sensor 180K, also known as a "touch device," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touchscreen." Touch sensor 180K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of electronic device 100, in a different position than display screen 194.

[0313] The bone conduction sensor 180M can acquire vibration signals. In some embodiments, the bone conduction sensor 180M can acquire vibration signals from the vibrating bone segments of the human vocal cords. The bone conduction sensor 180M can also contact the human pulse to receive blood pressure signals. In some embodiments, the bone conduction sensor 180M can also be incorporated into headphones to form bone conduction headphones. The audio module 170 can parse the voice signals from the vibrating bone segments of the vocal cords acquired by the bone conduction sensor 180M to realize voice functionality. The application processor can parse heart rate information from the blood pressure signals acquired by the bone conduction sensor 180M to realize heart rate detection functionality.

[0314] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.

[0315] Motor 191 can generate vibration alerts. Motor 191 can be used for incoming call vibration alerts or for touch vibration feedback. For example, different vibration feedback effects can correspond to touch operations performed on different applications (such as taking photos, playing audio, etc.). Motor 191 can also correspond to different vibration feedback effects for touch operations performed on different areas of the display screen 194. Different application scenarios (such as time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also be customized.

[0316] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.

[0317] The SIM card interface 195 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to make contact with and separate from the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 195 simultaneously. The multiple cards can be of the same or different types. The SIM card interface 195 is also compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to realize functions such as calls and data communication. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0318] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This embodiment of the invention uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.

[0319] Figure 11 This is an exemplary schematic diagram of the software structure of the electronic device 100 provided in the embodiments of this application.

[0320] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.

[0321] The application layer can include a series of application packages.

[0322] like Figure 11 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.

[0323] The data obtained by the applications from their respective servers during operation can all be considered as synchronized data in this embodiment. Furthermore, one application may correspond to one or more copies of the source files.

[0324] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.

[0325] like Figure 11 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.

[0326] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.

[0327] Content providers store and retrieve data, making that data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.

[0328] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.

[0329] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).

[0330] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.

[0331] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.

[0332] The Android Runtime consists of core libraries and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.

[0333] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.

[0334] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0335] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.

[0336] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.

[0337] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.

[0338] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0339] A 2D graphics engine is a graphics engine for 2D drawing.

[0340] The system library may also include a synchronization library. This synchronization library provides one or more methods that enable the electronic device 100 to execute the multi-file synchronization method provided in this embodiment. More specifically, any application at the application layer on the electronic device can call methods in the synchronization library to synchronize the synchronization data generated by that application.

[0341] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.

[0342] Figure 12 Another software architecture diagram of the electronic device 100 provided in the embodiments of this application.

[0343] like Figure 12 As shown, the electronic device 100 includes multiple functional modules, such as a cache management module, a cache scheduling module, and a network detection module.

[0344] The cache management module can determine the synchronization information of multiple source file replicas on the client. This synchronization information can include: the location of dirty pages, the number of dirty pages, whether the file is dirty, the proportion of dirty data to the total file data, the last modification time, the last synchronization time, and the amount of data involved in write operations. For details on how the cache management module determines this synchronization information, please refer to the section above. Figure 3 The textual description of step S304 is not repeated here.

[0345] The network detection module can determine the synchronization rate of the communication connection between the client and the server. For details on how the network detection module determines the synchronization rate of the communication connection between the client and the server, please refer to the above text. Figure 3 The textual description in step S306.

[0346] The cache scheduling module determines the synchronization priority of source file copies on the client and the number of files to be synchronized at one time. It receives synchronization information from the cache management module and the synchronization rate from the network probing module. The method by which the cache scheduling module determines the synchronization priority of source file copies on the client can be found in the above text. Figure 3 The textual description in step S306.

[0347] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".

[0348] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.

[0349] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.

Claims

1. A method for synchronizing multiple files, characterized in that, include: The client obtains multiple copies of the file from the server; The client determines the synchronization information of the multiple file copies, the synchronization information including the amount of data to be synchronized and the aging degree, the aging degree corresponding to the duration during which the file copies have not been synchronized; The client determines the synchronization priority of the multiple file copies based on the synchronization information of the multiple file copies and a first preset condition; The first preset conditions include: When the aging level of the file copy is within a first range, the synchronization priority of the file copy is related to the aging level of the file copy; When the aging level of the file copy is within the second range, the synchronization priority of the file copy is related to the amount of data of the file copy being synchronized.

2. The method according to claim 1, characterized in that, After the client determines the synchronization priority of the multiple file copies based on the synchronization information of the multiple file copies and the first preset condition, it also includes: The client determines the first synchronization rate; The client determines the set of files to be synchronized based on the first synchronization rate and the synchronization priority of the multiple file copies; The client synchronizes copies of files from the set of files to be synchronized.

3. The method according to claim 2, characterized in that, The client determines the first synchronization rate, specifically including: The client determines the historical synchronization rate, which is related to the amount of data synchronized in the past and the synchronization duration in the past. The client determines the first synchronization rate based on the historical synchronization rate.

4. The method according to claim 2, characterized in that, The client determines the set of files to be synchronized based on the first synchronization rate and the priority of the multiple file replicas, specifically including: The client determines the amount of data to be synchronized based on the first synchronization rate and the expected synchronization duration. The client determines the set of files to be synchronized based on the amount of data in the synchronized data and the synchronization priority of the multiple file copies.

5. The method according to claim 1, characterized in that, The synchronized data includes dirty data or write operations.

6. The method according to claim 1, characterized in that, The client determines synchronization information for multiple file copies, specifically including: The client determines the synchronization information of multiple file copies based on the page's dirty bit; Alternatively, the client may determine synchronization information for multiple file copies based on write operations.

7. The method according to claim 1, characterized in that, The synchronization information also includes at least one of the following: the location of dirty pages, the number of dirty pages, the proportion of synchronized data in the file, the most recent modification time, and the most recent synchronization time.

8. The method according to claim 1, characterized in that, The lower limit of the first range is greater than or equal to the upper limit of the second range; The synchronization priority of the file copy located in the first range is lower than the synchronization priority of the file copy located in the second range; File copies with lower synchronization priority will be synchronized first.

9. The method according to claim 1, characterized in that, The upper limit of the first range is less than the lower limit of the second range; The synchronization priority of the file copy located in the first range is higher than the synchronization priority of the file copy located in the second range; File copies with lower synchronization priority will be synchronized first.

10. The method according to any one of claims 1 to 9, characterized in that, The plurality of file copies includes a first file copy and a second file copy; The aging level of the first file copy is within the first range; When the aging level of the first file copy is less than that of the second file copy, the synchronization priority of the first file copy is greater than that of the second file copy. If the aging level of the first file copy is greater than that of the second file copy, the priority of the first file copy is lower than the synchronization priority of the second file copy. File copies with lower synchronization priority will be synchronized first.

11. The method according to claim 10, characterized in that, When the aging level of the first file copy is equal to that of the second file copy, and when the amount of synchronized data of the first file copy is less than the amount of synchronized data of the second file copy, the synchronization priority of the first file copy is less than that of the second file copy. When the aging level of the first file copy is equal to that of the second file copy, and when the amount of synchronized data of the first file copy is greater than the amount of synchronized data of the second file copy, the synchronization priority of the first file copy is greater than that of the second file copy.

12. The method according to claim 10, characterized in that, When the aging level of the first file copy is equal to that of the second file copy, the synchronization priority of the first file copy is equal to that of the second file copy.

13. The method according to any one of claims 1 to 9, characterized in that, The multiple file copies include a third file copy and a fourth file copy; The aging level of the third file copy is within the second range, and the aging level of the fourth file copy is also within the second range; If the amount of data in the synchronization data of the third file copy is less than the amount of data in the synchronization data of the fourth file copy, the synchronization priority of the third file copy is less than the synchronization priority of the fourth file copy. If the amount of data in the third file copy is greater than the amount of data in the fourth file copy, the synchronization priority of the third file copy is greater than the synchronization priority of the fourth file copy. File copies with lower synchronization priority will be synchronized first.

14. An electronic device, characterized in that, The electronic device includes: one or more processors and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program code, the computer program code including computer instructions, which the one or more processors invoke to cause the electronic device to execute: Obtain multiple copies of the file from the server; The synchronization information of the multiple file copies is determined, and the synchronization information includes the amount of data to be synchronized and the aging degree, wherein the aging degree corresponds to the duration during which the file copies have not been synchronized; The synchronization priority of the multiple file copies is determined based on the synchronization information of the multiple file copies and the first preset condition; The first preset conditions include: When the aging level of the file copy is within a first range, the synchronization priority of the file copy is related to the aging level of the file copy; When the aging level of the file copy is within the second range, the synchronization priority of the file copy is related to the amount of data of the file copy being synchronized.

15. The electronic device according to claim 14, characterized in that, The one or more processors are also configured to invoke the computer instructions to cause the electronic device to execute: Determine the first synchronization rate; The set of files to be synchronized is determined based on the first synchronization rate and the priority of the multiple file copies; Synchronize copies of files in the set of files to be synchronized.

16. The electronic device according to claim 15, characterized in that, The one or more processors are specifically used to invoke the computer instructions to cause the electronic device to execute: Determine the historical synchronization rate, which is related to the amount of data synchronized in the past and the synchronization duration of the past. The first synchronization rate is determined based on the historical synchronization rate.

17. The electronic device according to claim 15, characterized in that, The one or more processors are specifically used to invoke the computer instructions to cause the electronic device to execute: The amount of data to be synchronized is determined based on the first synchronization rate and the expected synchronization duration. The set of files to be synchronized is determined based on the amount of data in the synchronized data and the synchronization priority of the multiple file copies.

18. The electronic device according to claim 14, characterized in that, The synchronized data includes dirty data or write operations.

19. The electronic device according to claim 14, characterized in that, The one or more processors are specifically used to invoke the computer instructions to cause the electronic device to execute: The dirty bit, based on the page, determines the synchronization information for multiple file copies; Alternatively, synchronization information for multiple file copies can be determined based on write operations.

20. The electronic device according to claim 14, characterized in that, The synchronization information also includes at least one of the following: the location of dirty pages, the number of dirty pages, the proportion of synchronized data in the file, the most recent modification time, and the most recent synchronization time.

21. The electronic device according to claim 14, characterized in that, The lower limit of the first range is greater than or equal to the upper limit of the first range; The synchronization priority of the file copy located in the first range is lower than the synchronization priority of the file copy located in the second range; File copies with lower synchronization priority will be synchronized first.

22. The electronic device according to claim 14, characterized in that, The upper limit of the first range is less than the lower limit of the first range; The synchronization priority of the file copy located in the first range is higher than the synchronization priority of the file copy located in the second range; File copies with lower synchronization priority will be synchronized first.

23. The electronic device according to any one of claims 14 to 22, characterized in that, The plurality of file copies includes a first file copy and a second file copy; The aging level of the first file copy is within the first range; When the aging level of the first file copy is less than that of the second file copy, the synchronization priority of the first file copy is greater than that of the second file copy. If the aging level of the first file copy is greater than that of the second file copy, the priority of the first file copy is lower than the synchronization priority of the second file copy. File copies with lower synchronization priority will be synchronized first.

24. The electronic device according to claim 23, characterized in that, When the aging level of the first file copy is equal to that of the second file copy, and when the amount of synchronized data of the first file copy is less than the amount of synchronized data of the second file copy, the synchronization priority of the first file copy is less than that of the second file copy. When the aging level of the first file copy is equal to that of the second file copy, and when the amount of synchronized data of the first file copy is greater than the amount of synchronized data of the second file copy, the synchronization priority of the first file copy is greater than that of the second file copy.

25. The electronic device according to claim 23, characterized in that, When the aging level of the first file copy is equal to that of the second file copy, the synchronization priority of the first file copy is equal to that of the second file copy.

26. The electronic device according to any one of claims 14 to 22, characterized in that, The multiple file copies include a third file copy and a fourth file copy; The aging level of the third file copy is within the second range, and the aging level of the fourth file copy is also within the second range; If the amount of data in the synchronization data of the third file copy is less than the amount of data in the synchronization data of the fourth file copy, the synchronization priority of the third file copy is less than the synchronization priority of the fourth file copy. If the amount of data in the third file copy is greater than the amount of data in the fourth file copy, the synchronization priority of the third file copy is greater than the synchronization priority of the fourth file copy. File copies with lower synchronization priority will be synchronized first.

27. A chip system applied to an electronic device, the chip system comprising one or more processors, the processors being configured to invoke computer instructions to cause the electronic device to perform the method as claimed in any one of claims 1 to 13.

28. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on an electronic device, the electronic device causes the electronic device to perform the method as described in any one of claims 1 to 13.

Citation Information

Patent Citations

  • CN104008116A

  • CN111797065A