[Nexus 7 Android Development] gmikhail:
Finally, I was able to identify the cause of lags. As mentioned above, the swap partition is filled and not released, which causes the filling of RAM and lags.

https://i.imgur.com/nfrBvnm.png

If you close all applications, RAM and swap are released a little (see screenshot), but the lags will start again after a while.

https://i.imgur.com/q4fi7ax.png

Swap status immediately after reboot.

https://i.imgur.com/hyk4950.png

Here is a system log, but I did not find anything useful there (all errors are caused by a lack of memory). Also managed to catch the problem with black wallpaper (see log).

11-27 09:04:57.883 3833-3833/com.android.systemui W/FingerprintManager: isFingerprintHardwareDetected(): Service not connected!
11-27 09:04:58.125 442-2322/system_process W/art: Long monitor contention with owner Binder:442_12 (2069) at void com.android.server.am.ActivityManagerService.setLockScreenShown(boolean, boolean)(ActivityManagerService.java:11879) waiters=2 in java.lang.String com.android.server.am.ActivityManagerService.checkContentProviderAccess(java.lang.String, int) for 137ms
11-27 09:04:58.643 3833-3833/com.android.systemui W/ImageWallpaperGL: GL error = 0x501
java.lang.Throwable
at com.android.systemui.ImageWallpaper$DrawableEngine.checkGlError(ImageWallpaper.java:724)
at com.android.systemui.ImageWallpaper$DrawableEngine.loadTexture(ImageWallpaper.java:660)
at com.android.systemui.ImageWallpaper$DrawableEngine.drawWallpaperWithOpenGL(ImageWallpaper.java:581)
at com.android.systemui.ImageWallpaper$DrawableEngine.drawFrame(ImageWallpaper.java:415)
at com.android.systemui.ImageWallpaper$DrawableEngine$1.onPostExecute(ImageWallpaper.java:499)
at com.android.systemui.ImageWallpaper$DrawableEngine$1.onPostExecute(ImageWallpaper.java:482)
at android.os.AsyncTask.finish(AsyncTask.java:667)
at android.os.AsyncTask.-wrap1(AsyncTask.java)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6121)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
11-27 09:04:58.772 3833-3833/com.android.systemui I/Choreographer: Skipped 463 frames! The application may be doing too much work on its main thread.
11-27 09:04:58.876 3833-3833/com.android.systemui D/ViewRootImpl[StatusBar]: changeCanvasOpacity: opaque=true
11-27 09:05:01.485 3833-3920/com.android.systemui I/OpenGLRenderer: Initialized EGL, version 1.4
11-27 09:05:01.485 3833-3920/com.android.systemui D/OpenGLRenderer: Swap behavior 1
11-27 09:05:01.564 12655-3145/com.android.chrome E/cr_Icing: Connection to GmsCore unsuccessful. Error 14
11-27 09:05:01.700 3859-3859/com.google.android.gms.persistent W/ConfigurationChimeraPro: Got null configs for com.google.android.gms.backup
11-27 09:05:01.805 3859-3871/com.google.android.gms.persistent I/art: Background sticky concurrent mark sweep GC freed 14995(1156KB) AllocSpace objects, 6(120KB) LOS objects, 22% free, 4MB/5MB, paused 11.735ms total 237.620ms
11-27 09:05:03.370 442-503/system_process D/WifiService: New client listening to asynchronous messages
11-27 09:05:05.211 3833-3844/com.android.systemui I/art: Background partial concurrent mark sweep GC freed 27084(2MB) AllocSpace objects, 3(64KB) LOS objects, 34% free, 30MB/46MB, paused 19.833ms total 368.963ms
11-27 09:05:05.651 3859-3957/com.google.android.gms.persistent W/NearbyMessages: Runnable[resetNearbyDirect] ran for 00:05.231
11-27 09:05:05.680 3859-3957/com.google.android.gms.persistent W/NearbyMessages: Runnable[resubscribeOnGmsCoreRestart] was delayed for 00:05.789
11-27 09:05:06.083 3833-3833/com.android.systemui E/ImageWallpaperGL: requested texture size 2331x1920 exceeds the support maximum of 2048x2048
11-27 09:05:06.640 3859-3859/com.google.android.gms.persistent W/art: Verification of android.location.Location aojz.a(anxf, anxs) took 156.171ms
11-27 09:05:06.931 149-149/? E/GLConsumer: [com.android.systemui.ImageWallpaper] bindTextureImage: error binding external image: 0x502
11-27 09:05:07.052 3833-3833/com.android.systemui W/FingerprintManager: isFingerprintHardwareDetected(): Service not connected!
11-27 09:05:07.067 3833-3833/com.android.systemui W/FingerprintManager: isFingerprintHardwareDetected(): Service not connected!

Here's the emergency restart of the interface:

11-27 09:05:22.837 442-8803/system_process I/ActivityManager: Start proc 3985:com.android.systemui/u0a20 for restart com.android.systemui
11-27 09:05:22.857 442-18712/system_process W/VolumeController: Error calling dismiss
android.os.DeadObjectException
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:615)
at android.media.IVolumeController$Stub$Proxy.dismiss(IVolumeController.java:162)
at com.android.server.audio.AudioService$VolumeController.postDismiss(AudioService.java:6146)
at com.android.server.audio.AudioService.setVolumeController(AudioService.java:5994)
at com.android.server.audio.AudioService$4.binderDied(AudioService.java:6003)
at android.os.BinderProxy.sendDeathNotice(Binder.java:688)
11-27 09:05:23.056 442-456/system_process W/art: Long monitor contention with owner Binder:442_17 (8803) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1484) waiters=0 in void com.android.server.am.AppErrors.appNotResponding(com.android.server.am.ProcessRecord, com.android.server.am.ActivityRecord, com.android.server.am.ActivityRecord, boolean, java.lang.String) for 719ms
11-27 09:05:23.098 442-8802/system_process W/art: Long monitor contention with owner Binder:442_17 (8803) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1484) waiters=1 in void com.android.server.am.ActivityManagerService.finishReceiver(android.os.IBinder, int, java.lang.String, android.os.Bundle, boolean, int) for 734ms
11-27 09:05:23.103 442-1984/system_process W/art: Long monitor contention with owner Binder:442_17 (8803) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1484) waiters=2 in boolean com.android.server.am.ActivityManagerService.refContentProvider(android.os.IBinder, int, int) for 734ms
11-27 09:05:23.155 442-442/system_process W/art: Long monitor contention with owner Binder:442_17 (8803) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1484) waiters=3 in int com.android.server.am.ActivityManagerService.broadcastIntent(android.app.IApplicationThread, android.content.Intent, java.lang.String, android.content.IIntentReceiver, int, java.lang.String, android.os.Bundle, java.lang.String[], int, android.os.Bundle, boolean, boolean, int) for 666ms
11-27 09:05:23.164 442-964/system_process W/art: Long monitor contention with owner Binder:442_7 (976) at void com.android.server.wm.WindowManagerService$9.binderDied()(WindowManagerService.java:7027) waiters=1 in void com.android.server.wm.WindowState$DeathRecipient.binderDied() for 1.195s
11-27 09:05:23.164 442-964/system_process I/WindowManager: WIN DEATH: Window{5a6dee4 u0 com.android.systemui.ImageWallpaper}
11-27 09:05:23.165 442-964/system_process W/InputDispatcher: Attempted to unregister already unregistered input channel '5a6dee4 com.android.systemui.ImageWallpaper (server)'
11-27 09:05:23.223 442-848/system_process W/art: Long monitor contention with owner Binder:442_7 (976) at void com.android.server.wm.WindowManagerService$9.binderDied()(WindowManagerService.java:7027) waiters=2 in void com.android.server.wm.WindowState$DeathRecipient.binderDied() for 1.255s
11-27 09:05:23.224 442-848/system_process I/WindowManager: WIN DEATH: Window{f09d0ef u0 StatusBar}
11-27 09:05:23.224 442-848/system_process W/InputDispatcher: Attempted to unregister already unregistered input channel 'f09d0ef StatusBar (server)'
11-27 09:05:23.297 442-518/system_process W/art: Long monitor contention with owner Binder:442_17 (8803) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1484) waiters=4 in boolean com.android.server.am.ActivityManagerService.unbindService(android.app.IServiceConnection) for 533ms
11-27 09:05:23.346 442-16892/system_process W/ActivityManager: Slow operation: 57ms so far, now at attachApplicationLocked: before bindApplication
11-27 09:05:23.346 442-16892/system_process W/ActivityManager: Slow operation: 57ms so far, now at attachApplicationLocked: immediately before bindApplication
11-27 09:05:23.362 442-16892/system_process W/ActivityManager: Slow operation: 72ms so far, now at attachApplicationLocked: immediately after bindApplication
11-27 09:05:23.362 442-16892/system_process W/ActivityManager: Slow operation: 73ms so far, now at attachApplicationLocked: after updateLruProcessLocked
11-27 09:05:23.410 442-2069/system_process W/art: Long monitor contention with owner Binder:442_7 (976) at void com.android.server.wm.WindowManagerService$9.binderDied()(WindowManagerService.java:7027) waiters=3 in void com.android.server.wm.WindowState$DeathRecipient.binderDied() for 1.441s
11-27 09:05:23.410 442-2069/system_process I/WindowManager: WIN DEATH: Window{75bd356 u0 AssistPreviewPanel}
11-27 09:05:23.410 442-2069/system_process W/InputDispatcher: Attempted to unregister already unregistered input channel '75bd356 AssistPreviewPanel (server)'
11-27 09:05:23.416 442-2472/system_process W/art: Long monitor contention with owner Binder:442_7 (976) at void com.android.server.wm.WindowManagerService$9.binderDied()(WindowManagerService.java:7027) waiters=4 in void com.android.server.wm.WindowState$DeathRecipient.binderDied() for 1.448s
11-27 09:05:23.416 442-2472/system_process I/WindowManager: WIN DEATH: Window{e1380c4 u0 NavigationBar}
11-27 09:05:23.416 442-2472/system_process W/InputDispatcher: Attempted to unregister already unregistered input channel 'e1380c4 NavigationBar (server)'
11-27 09:05:23.417 442-16892/system_process W/ActivityManager: Slow operation: 128ms so far, now at attachApplicationLocked: after mServices.attachApplicationLocked
11-27 09:05:23.421 442-16892/system_process W/ActivityManager: Slow operation: 132ms so far, now at attachApplicationLocked: after updateOomAdjLocked
11-27 09:05:23.423 442-8810/system_process W/art: Long monitor contention with owner Binder:442_7 (976) at void com.android.server.wm.WindowManagerService$9.binderDied()(WindowManagerService.java:7027) waiters=5 in void com.android.server.wm.Session.binderDied() for 1.381s
11-27 09:05:23.425 442-455/system_process W/art: Long monitor contention with owner Binder:442_17 (8803) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1484) waiters=5 in void com.android.server.am.ActivityManagerService$3.handleMessage(android.os.Message) for 541ms
11-27 09:05:23.435 442-463/system_process W/art: Long monitor contention with owner Binder:442_B (1834) at void com.android.server.wm.WindowState$DeathRecipient.binderDied()(WindowState.java:1806) waiters=5 in void com.android.server.wm.WindowManagerService$H.handleMessage(android.os.Message) for 577ms
11-27 09:05:23.437 442-457/system_process W/art: Long monitor contention with owner Binder:442_17 (8803) at void com.android.server.am.ActivityManagerService$AppDeathRecipient.binderDied()(ActivityManagerService.java:1484) waiters=6 in void com.android.server.am.ActivityManagerService.dispatchUidsChanged() for 475ms
11-27 09:05:23.438 442-442/system_process W/art: Long monitor contention with owner Binder:442_16 (8802) at void com.android.server.am.ActivityManagerService.trimApplications()(ActivityManagerService.java:21394) waiters=3 in int com.android.server.am.ActivityManagerService.broadcastIntent(android.app.IApplicationThread, android.content.Intent, java.lang.String, android.content.IIntentReceiver, int, java.lang.String, android.os.Bundle, java.lang.String[], int, android.os.Bundle, boolean, boolean, int) for 179ms
11-27 09:05:23.699 442-457/system_process W/InputMethodManagerService: Window already focused, ignoring focus gain of: android.view.inputmethod.InputMethodManager$1@df82a8b attribute=null, token = android.view.ViewRootImpl$W@c975026

All data from the original ROM (without any modifications, only GApps) from this thread OP. Specially used a clean firmware to identify the cause of lags.

---

I did not yet have time for experiments, so if you find a solution before me - write a message here.